Double Quotes in Hadoop Hive Query

柔情痞子 提交于 2019-12-25 05:33:46

问题


I am able to use Double Quotes in following query ->

$subscriptionName = "***"
$clusterName = "***" 
$queryString = "SELECT city FROM logs WHERE city =""New York"";"
Use-AzureHDInsightCluster $clusterName
Invoke-Hive -Query $queryString

But I am not able to use Quotes in following PowerShell Comamnds -

$subscriptionName = "***"
$storageAccountName = "***"
$containerName = "***"
$clusterName = "***"

$queryString = "SELECT city FROM logs WHERE city =""New York"";"

$hiveJobDefinition = New-AzureHDInsightHiveJobDefinition -Query $queryString

Select-AzureSubscription $subscriptionName
$hiveJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $hiveJobDefinition

Wait-AzureHDInsightJob -Job $hiveJob -WaitTimeoutInSeconds 36000

Get-AzureHDInsightJobOutput -Cluster $clusterName -JobId $hiveJob.JobId -StandardOutput

It is giving me following error -

Please give me some information why is this sporadic behavior. Both implementations creates jobs, then why one implementation accepting double quotes and other not.


回答1:


Try a couple of alternate ways of quoting your query to see if you get any further:

Single Quotes

$queryString = 'SELECT city FROM logs WHERE city ="New York";'

Backtick Escape

$queryString = "SELECT city FROM logs WHERE city =`"New York`";"

My guess is that it is the way that Start-AzureHDInsightJob is interpreting the string differently.

Update 1

Sorry to hear the above didn't work, maybe try (single quote string):

$queryString = "SELECT city FROM logs WHERE city ='New York';"

Update 2

Looking at New-AzureHDInsightHiveJobDefinition you haven't specified a job name, if you don't specify a job name then the following applies:

The name of the Hive job being defined. If the name is not specified, 
it is "Hive: <first 100 characters of Query>" by default.

So your job name will contain your query, try specifying a job name to see if that helps.



来源:https://stackoverflow.com/questions/20897587/double-quotes-in-hadoop-hive-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!