您好,登錄后才能下訂單哦!
這篇文章給大家介紹sqoop中query \$CONDITIONS HUE執行失敗怎么辦,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
1. HUE sqoop命令框中直接輸入:
sqoop-import --connect jdbc:mysql://ip地址:端口/數據庫 --username 用戶名 --password 密碼 --query select * from 表名 where 1=1 and \$CONDITIONS --split-by id --hive-table hive表 --target-dir /apps/hive/warehouse/mydb.db/product/dt=${date} --hive-partition-key dt --hive-partition-value ${date} --hive-import --driver com.mysql.jdbc.Driver
運行會提示報錯,是因為SQL語句被解析成sqoop參數
2784 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Error parsing arguments for import:
2016-09-11 15:21:46,485 ERROR [main] tool.BaseSqoopTool (BaseSqoopTool.java:hasUnrecognizedArgs(304)) - Error parsing arguments for import:
2785 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Unrecognized argument: *
2016-09-11 15:21:46,486 ERROR [main] tool.BaseSqoopTool (BaseSqoopTool.java:hasUnrecognizedArgs(307)) - Unrecognized argument: *
2785 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Unrecognized argument: from
2016-09-11 15:21:46,486 ERROR [main] tool.BaseSqoopTool (BaseSqoopTool.java:hasUnrecognizedArgs(307)) - Unrecognized argument: from
2785 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Unrecognized argument: product
2016-09-11 15:21:46,486 ERROR [main] tool.BaseSqoopTool (BaseSqoopTool.java:hasUnrecognizedArgs(307)) - Unrecognized argument: p_product
2785 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Unrecognized argument: where
2016-09-11 15:21:46,486 ERROR [main] tool.BaseSqoopTool (BaseSqoopTool.java:hasUnrecognizedArgs(307)) - Unrecognized argument: where
2785 [main] ERROR org.apache.sqoop.tool.BaseSqoopTool - Unrecognized argument: $CONDITIONS
2. 解決方案: 最好采用參數化的方式
<workflow-app name="test" xmlns="uri:oozie:workflow:0.5">
<start to="sqoop-fb61"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="sqoop-fb61">
<sqoop xmlns="uri:oozie:sqoop-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<arg>import</arg>
<arg>--connect</arg>
<arg>"jdbc:mysql://IP地址:端口/數據庫"</arg>
<arg>--username</arg>
<arg>"用戶名"</arg>
<arg>--password</arg>
<arg>"密碼"</arg>
<arg>--query</arg>
<arg>select * from product where $CONDITIONS</arg> ## 注意:這個地方沒有反斜杠(\)
<arg>--split-by</arg>
<arg>"id"</arg>
<arg>--hive-table</arg>
<arg>"HIVE表名"</arg>
<arg>--target-dir</arg>
<arg>"/apps/hive/warehouse/mydb.db/product/dt=${date}"</arg>
<arg>--hive-partition-key</arg>
<arg>"dt"</arg>
<arg>--hive-partition-value</arg>
<arg>"${date}"</arg>
<arg>--hive-import</arg>
<arg>--driver</arg>
<arg>"com.mysql.jdbc.Driver"</arg>
</sqoop>
<ok to="End"/>
<error to="Kill"/>
</action>
<end name="End"/>
</workflow-app>
關于sqoop中query \$CONDITIONS HUE執行失敗怎么辦就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。