hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sumit ghosh <sumi...@yahoo.com>
Subject Re: Variable resolution Fails
Date Wed, 01 May 2013 18:48:11 GMT
Thanks for the solution & the tip. :)



________________________________
From: Sanjay Subramanian <Sanjay.Subramanian@wizecommerce.com>
To: "user@hive.apache.org" <user@hive.apache.org>; sumit ghosh <sumitkg@yahoo.com>

Sent: Tuesday, 30 April 2013 7:44 PM
Subject: Re: Variable resolution Fails



+1  agreed

Also as a general script programming practice I check if the variables I am going to use are
NON empty before using them…nothing related to Hive scripts

If [ ${freq} == "" ]
then
   echo "variable freq is empty…exiting"
   exit 1
Fi


From: Anthony Urso <anthonyu@cs.ucla.edu>
Reply-To: "user@hive.apache.org" <user@hive.apache.org>
Date: Tuesday, April 30, 2013 7:20 PM
To: "user@hive.apache.org" <user@hive.apache.org>, sumit ghosh <sumitkg@yahoo.com>
Subject: Re: Variable resolution Fails


Your shell is expanding the variable ${env:freq}, which doesn't exist in the shell's environment,
so hive is getting the empty string in that place.  If you are always intending to run your
query like this, just use ${freq} which will be expanded as expected by bash and then passed
to hive.


Cheers,
Anthony


On Tue, Apr 30, 2013 at 4:40 PM, sumit ghosh <sumitkg@yahoo.com> wrote:

Hi,
>
>The following variable freq fails to resolve:
>
>bash-4.1$ export freq=MNTH
>bash-4.1$ echo $freq
>MNTH
>bash-4.1$ hive -e "select ${env:freq} as dr  from dual"
>Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
>Hive history file=/hadoop1/hive_querylog/sumighos/hive_job_log_sumighos_201304302321_1867815625.txt
>FAILED: ParseException line 1:8 cannot recognize input near 'as' 'dr' 'from' in select
clause 
>bash-4.1$
>
>Here dual is a table with 1 row.
>What am I am doing wrong? When I try to resolve freq - it is empty!!
>
>
>  $ hive -S -e "select '${env:freq}' as dr  from dual"
> 
>  $
> 
>Thanks,
>Sumit


CONFIDENTIALITY NOTICE
======================
This email message and any attachments are for the exclusive use of the intended recipient(s)
and may contain confidential and privileged information. Any unauthorized review, use, disclosure
or distribution is prohibited. If you are not the intended recipient, please contact the sender
by reply email and destroy all copies of the original message along with any attachments,
from your computer system. If you are the intended recipient, please be advised that the content
of this message is subject to access, review and disclosure by the sender's Email System Administrator.
Mime
View raw message