Storing result of query in hive variable

前端 未结 1 395
滥情空心
滥情空心 2021-01-16 10:42

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

相关标签:
1条回答
  • 2021-01-16 11:17

    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'
    
    0 讨论(0)
提交回复
热议问题