本文介绍了将查询结果存储在 hive 变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Hive 中,如何将查询结果存储在变量中?我试过下面的命令:SET hivevar:a=(查询);
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 stored.Is there any way for storing the results?
推荐答案
Hive 变量只不过是一种文本替换机制.
替换在解析和执行之前完成.
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
将查询结果作为参数传递给另一个查询可以在 shell 中完成,例如-
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'
这篇关于将查询结果存储在 hive 变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!