本文介绍了将查询结果存储在配置单元变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Hive中,如何将查询的结果存储在变量中?
我试过了下面的命令:
SET hivevar:a =(Query);

但是结果并不是这样,查询本身越来越多存储。
是否有任何存储结果的方法?

解决方案

Hive变量只不过是一种文本替换机制。 >
在解析和执行之前完成替换。

  hive>设置hivevar:v1 = se; 
hive>设置hivevar:v2 = 1;
hive>设置hivevar:v3 = ec;
hive>设置hivevar:v4 = t 1+;
hive>设置hivevar:v5 = 2;
hive> $ {hivevar:V1} $ {hivevar:V2} $ {hivevar:V3} $ {hivevar:V4} $ {hivevar:V5};
OK
3

将查询结果作为参数传递给另一个查询从壳上完成,例如 -

  hive --hivevar x = $(hive -e'select 1 + 2')-e'select $ {hivevar :x} * 100'


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 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'

这篇关于将查询结果存储在配置单元变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 09:16