簡體   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