一、介绍
例子:
$ a=b
$ hive -e " describe $a "
如果你hive数据库中没有b这个表,则会提示Table b does not exist
hive的变量设置可以放在hiveconf中,使变量赋值与查询合并为一句话:
例子:
$ bin/hive -hiveconf a=b -e 'set a; set hiveconf:a; \
create table if not exists b (col int); describe ${hiveconf:a}'
Results in:
Hive history file=/tmp/edward/hive_job_log_edward_201011240906_1463048967.txt
a=b
hiveconf:a=b
OK
Time taken: 5.913 seconds
OK
col int
Time taken: 0.754 seconds
二、hive变量使用
hive的变量有3个作用空间hiveconf,system,env。hiveconf就像平时一样设置:
set x=myvalue
X变量会被这样调用:
${hiveconf:x}
Annotated examples of usage from the test case
ql/src/test/queries/clientpositive/set_processor_namespaces.q
set zzz=5;
-- sets zzz=5
set zzz;
set system:xxx=5;
set system:xxx;
-- sets a system property xxx to 5
set system:yyy=${system:xxx};
set system:yyy;
-- sets yyy with value of xxx
set go=${hiveconf:zzz};
set go;
-- sets go base on value on zzz
set hive.variable.substitute=false;
set raw=${hiveconf:zzz};
set raw;
-- disable substitution set a value to the literal
set hive.variable.substitute=true;
EXPLAIN SELECT * FROM src where key=${hiveconf:zzz};
SELECT * FROM src where key=${hiveconf:zzz};
--use a variable in a query
set a=1;
set b=a;
set c=${hiveconf:${hiveconf:b}};
set c;
--uses nested variables.
set jar=../lib/derby.jar;
add file ${hiveconf:jar};
list file;
delete file ${hiveconf:jar};
list file;
三、Disabling
Variable substitution is on by default. If this causes an issue with an already existing script disable it.
set hive.variable.substitute=false;
分享到:
相关推荐
配置hive-0.9.0和hbase-0.94.1结合使用,部分内容如下: 1.拷贝hbase-0.94.1.jar和zookeeper-3.4.3.jar到hive/lib下。 注意:如hive/lib下已经存在这两个文件的其他版本,建议删除后使用hbase下的相关版本。 //...
hive-0.9.0 是一个安装好了的程序包 在安装好hadoop和mysql的机器上面解压了 配置了就可以直接使用、
hive-0.10.0-cdh4.3.0.tar.gz liux安装文件 64位
压缩包中包含Java通过JDBC连接Hive所需的jar包。包含有,antlr-runtime-3.0.1.jar;commons-logging-1.0.4.jar;hadoop-core-1.2.1.jar;hive-exec-0.10.0.jar;hive-jdbc-0.13.1.jar;hive-metastore-0.9.0.jar;hive-...
java连接jdbc使用到的13个jar包:commons-logging-1.0.4,hadoop_fat,hadoop-common-2.0.0-cdh4.7.0,hive-common-0.10.0-cdh4.7.0,hive-jdbc-0.10.0-cdh4.7.0,hive-metastore-0.10.0-cdh4.7.0,hive-service-0.10.0-...
hive-1.2.1+tez-0.9.0+hadoop-2.7.7 hive-2.3.6+tez-0.9.0+hadoop-2.7.1 两种搭配均试过可行,之前配置的时候觉得与版本有很大关系,试过之后发现版本影响不大,还没发现有问题
hadoop-hbase-hive-zookeeper的cdh4.6.0和spark-0.9.0-incubating-bin-cdh4集群配置文件
commons-logging-1.1.3.jar commons-collections-3.1.jar hive-exec-0.13.1.jar hive-jdbc-0.13.1.jar hive-metastore-0.13.1.jar hive-service-0.13.1.jar libfb303-0.9.0.jar ...hadoop-common-2.4.0.jar
KMV的MATLAB的代码欢迎来到砖房 Brickhouse是Hive的UDF的集合,以提高开发人员的生产力以及....jar”添加到您的HIVE_AUX_JARS_FILE_PATH,或使用“ add jar”命令从Hive CLI将其添加到分布式缓存中 源src / main / res
KMV的MATLAB的代码欢迎来到砖房 Brickhouse是Hive的UDF的集合,以提高开发人员的生产力以及....jar”添加到您的HIVE_AUX_JARS_FILE_PATH,或使用“ add jar”命令从Hive CLI将其添加到分布式缓存中 源src / main / res
带有 HDP-2.1 和 Apache Spark-... 默认情况下, SPARK_HOME=/usr/lib/spark/1.3.0和 Apache Spark 1.3.0 构建时支持hive (Spark SQL)。 如何使用? docker pull ypandit/hdp-spark docker run -td ypandit/hdp-spark