问题
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