[英]How to write hive script for return result in shell variable in an Oozie coordinator?
Then i coordinate my script.sh in an Oozie there is nothing in a variables S. Here is shell script 然后我在Oozie中协调我的script.sh,变量S中什么也没有。这是shell脚本
S=$(hive -S -hiveconf MY_VAR1=$DB -hiveconf MY_VAR2=$avgpay -hiveconf MY_VAR3=$Date_LastDay -hiveconf MY_VAR4=$Date_LastNmonth -f bpxp.hql)
echo $S "S"
S1=( $( for k in $S ; do echo $k ; done ) )
cntn=${#S1[@]}
for (( p=0 ; p<$cntn; p=p+5 ))
do
`mysql -h$mysqlhost -u$mysqluser -p$mysqlpass $mysqldb -e "INSERT INTO weekstat (timeshift, partnerid, avg_value, processdate, weekday) VALUES ('${S1[p]}', '${S1[p+1]}', '${S1[p+2]}', '${S1[p+3]}', '${S1[p+4]}');"`
done
Mysql commands works fine with another variables Here is bpxp.hql Mysql命令与另一个变量一起正常工作这是bpxp.hql
...
hive -e "select * from ${hiveconf:MY_VAR1}.weekstat;"
Then i run script from shell it works fine. 然后我从外壳运行脚本,它工作正常。 I try to use bpxp.hql without this line
hive -e "select * from ${hiveconf:MY_VAR1}.weekstat;"
我尝试在不带这一行的情况下使用bpxp.hql
hive -e "select * from ${hiveconf:MY_VAR1}.weekstat;"
and write it in shell S= hive -e "select * from $DB.weekstat;"
并将其写入shell S =
hive -e "select * from $DB.weekstat;"
but nothing change. 但没有改变。 Where is my mistake?
我的错误在哪里?
Whatever you done is an efficient way, but minor change as mentioned below: 无论您做什么,都是一种有效的方法,但是要进行如下所述的微小更改:
S=$(hive -S -hiveconf MY_VAR1=$DB -hiveconf MY_VAR2=$avgpay -hiveconf MY_VAR3=$Date_LastDay -hiveconf MY_VAR4=$Date_LastNmonth -f bpxp.hql)
In bpxp.hql keep the query 在bpxp.hql中保留查询
select * from $DB.weekstat;
You don't need to mention hive -e in the hql script, the command above will automatically executes and gives you the output, and stores into S. 您无需在hql脚本中提及hive -e,上面的命令将自动执行并提供输出,并存储到S中。
Please let me correct if I'm wrong. 如果我错了,请让我纠正。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.