In Hive,how to store the results of a query in a variable? I\'ve tried the below command: SET hivevar:a=(Query);
But instead of the result,query itself is getting st
Hive variables are nothing but a text replacement mechanism.
The replacement is done before parsing and execution.
hive> set hivevar:v1=se;
hive> set hivevar:v2=l;
hive> set hivevar:v3=ec;
hive> set hivevar:v4=t 1+;
hive> set hivevar:v5=2;
hive> ${hivevar:v1}${hivevar:v2}${hivevar:v3}${hivevar:v4}${hivevar:v5};
OK
3
Passing a query result as an argument to another query can be done from the shell, e.g. -
hive --hivevar x=$(hive -e 'select 1+2') -e 'select ${hivevar:x}*100'