繁体   English   中英

需要使用Hive将Shell Action中的变量传递给Oozie Shell

[英]Need to pass Variable from Shell Action to Oozie Shell using Hive

所有,

希望将变量从shell动作传递给oozie shell。 我在我的脚本中运行这样的命令:

#!/bin/sh
evalDate="hive -e 'set hive.execution.engine=mr; select     max(cast(create_date as int)) from db.table;'"
evalPartition=$(eval $evalBaais)
echo "evaldate=$evalPartition"

诀窍是它是shell中的hive命令。

然后我运行它来获取它在oozie中:

${wf:actionData('getPartitions')['evaldate']}

但它每次都是空白! 我可以在我的shell中运行这些命令很好,它似乎工作,但oozie没有。 同样,如果我在群集的其他框上运行命令,它们也可以正常运行。 有任何想法吗?

问题是关于我的集群的配置。 当我作为oozie用户运行时,我向/ tmp / yarn写了权限问题。 有了它,我改变命令运行为:

baais =“export HADOOP_USER_NAME = functionalid; hive yarn -hiveconf hive.execution.engine = mr -e'select db(show(create_date as int))from db.table;'”

蜂巢允许我作为纱线运行。

您的问题的解决方案是在hive命令中使用“-S”开关进行静默输出。 (见下文)

另外,什么是“evalBaais”? 您可能需要将其替换为“evalDate”。 所以你的代码应该是这样的 -

#!/bin/sh
evalDate="hive -S -e 'set hive.execution.engine=mr; select            max(cast(create_date as int)) from db.table;'"
evalPartition=$(eval $evalDate)
echo "evaldate=$evalPartition"

现在你应该能够抓住它了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM