2015-06-19 16 views
4

全部,需要將變量從Shell Action傳遞到使用Hive的Oozie Shell

尋找將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中的配置單元命令。

然後我運行這個得到它在Oozie的:

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

但它拉一個空白的每一次!我可以在我的shell中運行這些命令,它似乎工作,但oozie不。同樣,如果我在羣集的其他框上運行命令,它們也可以很好地運行。有任何想法嗎?

+0

我不確定您是否可以從shell操作調用配置單元查詢。我建議你對配置單元查詢使用配置單元操作,然後傳遞可以捕獲的參數。另外不要忘記使用 KKa

+1

嗯,我不認爲你可以保存Hive動作的輸出。從我的研究看來,你可以爲shell/ssh/java操作,但Hive不能像寫入磁盤那樣操作。我之前爲Sqoop運行過類似的操作 - 爲什麼它對於Sqoop而不是Hive? – theMJof91

回答

1

問題是關於我的集羣的配置。當我作爲oozie用戶運行時,我有權限寫入/ tmp/yarn。因此,我改變了命令運行:

baais =「export HADOOP_USER_NAME = functionalid; hive yarn -hiveconf hive.execution.engine = mr -e'從db中選擇max(cast(create_date as int))。 ';'

蜂巢讓我可以像紗一樣運行。

0

解決您的問題的方法是在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" 

現在你應該能夠捕捉出來。

相關問題