Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Setting variables for hive??

Setting variables for hive??

New Contributor

Hello everybody

i just downloaded the sandbox and i use hive through ambari for querying data. I m trying to understand how to define and use variables. I wrote this but it doesn't work:

set hivevar:mavar1='Ford';

set hivevar:mavar2=12058;

select * from tempo where model=${hiveconf:mavar1}

and ${hiveconf:marvar2};

Could you help me please?

1 REPLY 1
Highlighted

Re: Setting variables for hive??

Explorer

@hadoop user

Could you try issuing your select statement something like this -

"select * from tempo where model=${mavar1} and ${marvar2};"

I tried a similar thing on Hive CLI and it worked.

hive> create table test(i int,s string);

hive> insert into test values (1,'aa'),(2,'bb');

hive> set hivevar:testvar=1;

hive> select * from test where i=${testvar};

OK

1aa

Time taken: 0.261 seconds, Fetched: 1 row(s)

Don't have an account?
Coming from Hortonworks? Activate your account here