Sqoop导入oracle表查询抛出错误

时间:2016-11-03 19:28:41

标签: sql oracle sqoop

我正在使用此查询

sqoop import \
--connect jdbc:oracle:thin:@dbs-dev-vm-3001.cisco.com:1585:WIILDEV \
 --username MUSERNAME\
 --password MPASSWORD \
 --query 'select US_WORKERS_COMPENSATION_CD from wfrapub.cwa_job where FISCAL_YEAR_WK_NUMBER in (select FISCAL_YEAR_WK_NUMBER from wfrapub.CWA_FISCAL_WEEK_TO_YEAR where FISCAL_QTW_FLAG='Y') WHERE  $CONDITIONS' \
 --split-by FISCAL_YEAR_WK_NUMBER \
 --hive-table WFRAPUB.CWA_JOB2  \
 --target-dir /tmp/cwa_job2256 

我得到这个错误 -

ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter

但是,如果我将查询修改为

 --query 'select FISCAL_YEAR_WK_NUMBER from wfrapub.CWA_FISCAL_WEEK_TO_YEAR  WHERE  $CONDITIONS' \'

然后scoop导入正在运行。是因为在Sqoop没有处理的连接?该查询肯定适用于Toad。这种语法错误的原因是什么?

1 个答案:

答案 0 :(得分:2)

你的查询有点复述,基本上如下:

SELECT stuff FROM table WHERE some_column IN (...subquery...) WHERE ...

第二个WHERE错了。请尝试以下方法,

SELECT stuff FROM table WHERE some_column IN (...subquery...) AND ...