如何查看配置单元变量的计算值 [英] How to view the calculated value of a hive variable

查看:96
本文介绍了如何查看配置单元变量的计算值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查看配置单元中的计算值的值.例如,我正在尝试从该表名获取年份:

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)

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

我想得到的是计算值"2014".我怎么看这个值?

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

谢谢

推荐答案

配置单元变量"实际上只不过是一种文本替换机制.
替换是在解析和执行之前完成的.

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

这篇关于如何查看配置单元变量的计算值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆