这篇文章给大家介绍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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。