问题
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