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>&quot;jdbc:mysql://IP地址:端口/数据库&quot;</arg>
              <arg>--username</arg>
              <arg>&quot;用户名&quot;</arg>
              <arg>--password</arg>
              <arg>&quot;密码&quot;</arg>
              <arg>--query</arg>
              <arg>select * from product where $CONDITIONS</arg>    ## 注意:这个地方没有反斜杠(\)
              <arg>--split-by</arg>
              <arg>&quot;id&quot;</arg>
              <arg>--hive-table</arg>
              <arg>&quot;HIVE表名&quot;</arg>
              <arg>--target-dir</arg>
              <arg>&quot;/apps/hive/warehouse/mydb.db/product/dt=${date}&quot;</arg>
              <arg>--hive-partition-key</arg>
              <arg>&quot;dt&quot;</arg>
              <arg>--hive-partition-value</arg>
              <arg>&quot;${date}&quot;</arg>
              <arg>--hive-import</arg>
              <arg>--driver</arg>
              <arg>&quot;com.mysql.jdbc.Driver&quot;</arg>
        </sqoop>
        <ok to="End"/>
        <error to="Kill"/>
    </action>
    <end name="End"/>
</workflow-app>

转载于:https://my.oschina.net/summerdk/blog/745416

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值