首页 > 其他 > 详细

hive 脚本传参

时间:2019-10-15 10:03:50      阅读:135      评论:0      收藏:0      [点我收藏+]

hive 脚本传参

20190909


向hive脚本中传入参数,两种情况:

一、shell脚本调度hive脚本, hive可以直接读取系统变量和环境变量

  • hive脚本
--#test.sql
use huh;
select '${env:month}' as month from table_name;
  • 脚本传参
--#start.sh
#!/bin/sh
set -x
export month=`date -d 'last month' +%Y-%m`
hive -f test.sql

二、使用-hivevar 和 -hiveconf 两种参数选项

  • hive脚本
-- #test.sql
use huh;
select '${hiveconf:month}' as month from table_name;
#select '${hivevar:month}' as month from table_name;
  • 脚本传参
--#start.sh
#!/bin/sh
set -x
month=`date -d 'last month' +%Y-%m`
hive -hiveconf month=$month -f test.sql
#hive -hivevar month=$month -f test.sql

未完。。。

参考文献

CSDN-参考1

hive 脚本传参

原文:https://www.cnblogs.com/damahuhu/p/11675593.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!