How to view the calculated value of a hive variable

随声附和 提交于 2020-01-14 16:44:32

问题


I'm trying to see the value of a calculated value in hive. For example, I'm trying to get the year from this tablename:

set TABLE_NAME = orders2014;
set TABLE_YEAR = substr(${hiveconf:TABLE_NAME},6,4);
set TABLE_YEAR;

The result I get is the uncalculated string;

substr(${hiveconf:TABLE_NAME},6,4)

What I would like to get is the calculated value, "2014". How would I see this value?

Thanks


回答1:


Hive "variables" are actually nothing more than 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


来源:https://stackoverflow.com/questions/42958243/how-to-view-the-calculated-value-of-a-hive-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!