hive使用变量

来源:互联网 发布:html是不是编程语言 编辑:程序博客网 时间:2024/06/07 10:53

使用set设置变量

hive> set name=lucy; hive> set name;name=lucyhive> select * from employee where name='${hiveconf:name}';Total jobs = 1Launching Job 1 out of 1Number of reduce tasks is set to 0 since there's no reduce operatorStarting Job = job_1471442913162_0001, Tracking URL = http://ubuntu:8088/proxy/application_1471442913162_0001/Kill Command = /app/bigdata/hadoop-2.7.2/bin/hadoop job  -kill job_1471442913162_0001Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 02016-08-18 19:25:50,915 Stage-1 map = 0%,  reduce = 0%2016-08-18 19:26:00,758 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 1.64 secMapReduce Total cumulative CPU time: 1 seconds 640 msecEnded Job = job_1471442913162_0001MapReduce Jobs Launched: Job 0: Map: 1   Cumulative CPU: 1.64 sec   HDFS Read: 374 HDFS Write: 90 SUCCESSTotal MapReduce CPU Time Spent: 1 seconds 640 msecOKlucy    11000.0 ["tom","jack","dave","kate"]    {"tom":1200.0,"jack":1560.0}    {"street":"beijing","city":"changanjie","state":"xichengqu","zip":10000}Time taken: 28.615 seconds, Fetched: 1 row(s)

使用系统变量

root@ubuntu:~# envXDG_SESSION_ID=13TERM=xtermSHELL=/bin/bash……HOME=/rootLANGUAGE=en_US:LOGNAME=root……

employee有两条数据,打印两条

hive> select '${env:HOME}' from employee;Total jobs = 1Launching Job 1 out of 1Number of reduce tasks is set to 0 since there's no reduce operatorStarting Job = job_1471442913162_0002, Tracking URL = http://ubuntu:8088/proxy/application_1471442913162_0002/Kill Command = /app/bigdata/hadoop-2.7.2/bin/hadoop job  -kill job_1471442913162_0002Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 02016-08-18 19:30:19,926 Stage-1 map = 0%,  reduce = 0%2016-08-18 19:30:29,449 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 1.2 secMapReduce Total cumulative CPU time: 1 seconds 200 msecEnded Job = job_1471442913162_0002MapReduce Jobs Launched: Job 0: Map: 1   Cumulative CPU: 1.2 sec   HDFS Read: 374 HDFS Write: 12 SUCCESSTotal MapReduce CPU Time Spent: 1 seconds 200 msecOK/root/rootTime taken: 24.098 seconds, Fetched: 2 row(s)
0 0
原创粉丝点击