Hive下的变量使用
$ hive --define a='a' --define b='b'
??
对于使用hivevar,前缀是可有可无的,如:
hive> create table toss1(i int, ${hivevar:foo} string);等价于
hive> create table toss2(i2 int, ${foo} string);??
但是对于使用命名空间如hiveconf,system,env的,前缀则不可少
在hive下面,可以通过
set;
或者
set -v;?
来查看现有环境的所有变量的值。加上 -v参数,可以获取到HDFS和MapReduce的环境变量信息。
?
一个简单的Sample
hive> set CURRENT_DATE='2012-09-16';hive> select * from foo where day >= '${hiveconf:CURRENT_DATE}'similarly, you could pass on command line:hive -f xxx.hql$ hive -hiveconf CURRENT_DATE='2012-09-16' -hiveconf CURRENT_DATE='2012-09-16' -f test.hql?