20190909
向hive脚本中传入参数,两种情况:
一、shell脚本调度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 两种参数选项
-- #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
未完。。。
原文:https://www.cnblogs.com/damahuhu/p/11675593.html