Hive命名空间-自定义变量

Hive命名空间

Hive的命名空间分为:hiveconf , system, env 和 hivevar
1、hiveconf 的命名空间指的是hive-site.xml下面配置的环境变量
2、system的命名空间是系统的变量,包含JVM的运行信息
3、evn的命名空间是指环境变量,包含Shell环境下的变量信息,如 HADOOP_HOME一类的
4、hivevar为临时变量
可以使用:

$ hive --define foo=bar
hive> set foo;
foo=bar;

hive> set hivevar:foo;
hivevar:foo=bar;

hive> set hivevar:foo=bar2;

hive> set foo;
foo=bar2

hive> set hivevar:foo;
hivevar:foo=bar2

在 hivevar 的使用的时候,可以省略掉 命名空间的使用,直接使用 对于其他的命名空间的使用,必须要带上命名空间,如:{hiveconf:key}

在hive下面可以通过 set 或者 set -v 来查看现有环境所有变量的值。加上 -v 可以查看 HDFS和 MR 的环境变量信息
example:

hive> create table toss1(i int, ${hivevar:foo} string);
hive> describe toss1;
ve> describe toss1;
i        int
bar2      string
hive> create table toss2(i2 int, ${foo} string);
hive> describe toss2;
i2      int
bar2     string
hive> drop table toss1;
hive> drop table toss2

在这里插入图片描述
Hive中所有的内置属性都在$HIVE_HOME/conf/hivedefault.xml.template中列举出来了,这是个“样例”配置文件。配置文件中还说明了这些属性的默认值。

猜你喜欢

转载自blog.csdn.net/weixin_45639174/article/details/113769761