【发布时间】:2014-01-06 03:46:04
【问题描述】:
我有一个 Azure Blob 存储。在一个名为 DATA 的容器中,我以下列方式拥有 CSV blob -
现在我已经使用 HDInsight 创建了一个 Hadoop 集群。
作为下一部分,我想创建 Hive 表以进行查询。在这里我有一些具体的问题。
1) 如何在单个查询中将所有 BLOBS 加载到 Hive 表?
对于单个 BLOB,我可以使用以下查询。但是如何在单个查询中对 MULTIPLE Blob 执行此操作?
# Use the external table option.
$queryString = "DROP TABLE log4jLogs;" +
"CREATE EXTERNAL TABLE log4jLogs(t1 string, t2 string, t3 string, t4 string, t5 string, t6 string, t7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' STORED AS TEXTFILE LOCATION 'wasb://$containerName@$storageAccountName.blob.core.windows.net/example/data/';" +
"SELECT t4 AS sev, COUNT(*) AS cnt FROM log4jLogs WHERE t4 = '[ERROR]' GROUP BY t4;"
2) LOAD DATA 和 EXTERNAL TABLE 在创建 Hive Table 时的主要区别是什么?
任何输入都会有所帮助。
###################### UPDATE1 #################### #
我遵循了以下建议,但无法使其适用于 ONE BLOB。
我的 BLOB 是 CSV。我通过powershell从本地上传到blob存储。此 Blob 存储和容器获得了 HDInsight 的默认示例。 Blob 数据如下所示。
- 1,Rami,Vemula,29
- 2,杰克,阿斯顿,33
我的 Hive 查询 -
# Provide Windows Azure subscription name, and the Azure Storage account and container that is used for the default HDInsight file system.
$subscriptionName = "Rami"
$storageAccountName = "storagename"
$containerName = "containername"
# Provide HDInsight cluster name Where you want to run the Hive job
$clusterName = "clustername"
# Use the external table option.
$queryString = "DROP TABLE mylogss;" +
"CREATE EXTERNAL TABLE mylogss(t1 string, t2 string, t3 string, t4 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE LOCATION 'wasb://$containerName@$storageAccountName.blob.core.windows.net/blobrami/';" +
"SELECT COUNT(*) AS cnt FROM mylogss;"
# Create a Hive job definition
$hiveJobDefinition = New-AzureHDInsightHiveJobDefinition -Query $queryString
# Submit the job to the cluster
Select-AzureSubscription $subscriptionName
$hiveJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $hiveJobDefinition
# Wait for the Hive job to complete
Wait-AzureHDInsightJob -Job $hiveJob -WaitTimeoutInSeconds 3600
结果 -
所以最后我无法获得任何输出。它以代码 1 退出。我不确定我做错了什么。
【问题讨论】: