sqoop Oracle to hive出现 Error Msg = ORA-00933: SQL 命令未正确结束

原sqoop脚本:

bash 复制代码
sqoop import \
--connect "jdbc:oracle:thin:@//10.82.88.223:61521/LZY2" \
--username LZSHARE \
--password 'LZ^share$5105' \
--driver oracle.jdbc.driver.OracleDriver \
--query "SELECT 
    TO_NUMBER(TO_CHAR(GCRQ, 'YYYY')) AS gcrq_year,
    TO_NUMBER(TO_CHAR(GCRQ, 'MM')) AS gcrq_month,
    TO_NUMBER(TO_CHAR(GCRQ, 'DD')) AS gcrq_day,
    YEAR,
    GCRQ,
    GCZBS,
    HOUR,
    MINUTE,
    CDH,
    XSFX,
    SBSBM,
    DCSJLX,
    SJXH,
    CLZQ,
    XKC,
    DKC,
    XHC,
    ZHC,
    DHC,
    TDH,
    JZX,
    MTC,
    TLJ,
    XKCS,
    DKCS,
    XHCS,
    ZHCS,
    DHCS,
    TDHS,
    JZXS,
    MTCS,
    TLJS,
    GCBFB,
    PJCTJJ,
    SJZYL,
    FLAGS,
    OFF_MINS,
    ERR_CODE,
    ERR_DESC,
    DELETE_BY,
    DELETE_TIME,
    CREATE_BY,
    CREATE_TIME,
    UPDATE_BY,
    UPDATE_TIME,
    INSERT_TIME
FROM LZJHGX.DAT_DCSJ_TIME 
WHERE TO_CHAR(GCRQ , 'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD') AND \$CONDITIONS" \
--split-by "YEAR" \
--hive-import \
--hive-table ods_pre_dat_dcsj_time \
--hive-partition-key "gcrq_year,gcrq_month,gcrq_day" \
--target-dir /user/hive/warehouse/ods_pre_dat_dcsj_time \
--hive-partition-value "gcrq_year=${gcrq_year},gcrq_month=${gcrq_month},gcrq_day=${gcrq_day}" \
-- --hive-drop-import-delims

出现

关键在于sqoop在计算split-by切片字段时:OriginalSql = SELECT MIN(YEAR), MAX(YEAR) FROM (SELECT

TO_NUMBER(TO_CHAR(GCRQ, 'YYYY')) AS gcrq_year,

TO_NUMBER(TO_CHAR(GCRQ, 'MM')) AS gcrq_month,

TO_NUMBER(TO_CHAR(GCRQ, 'DD')) AS gcrq_day,

.......

FROM LZJHGX.DAT_DCSJ_TIME

WHERE TO_CHAR(GCRQ , 'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD') AND (1 = 1) ) AS t1,

使用 AS t1的语法,Oracle是不支持select * from (select * from A) as t1,这种子查询AS 命名表名的写法。

那么sqoop脚本中如何避免呢?

解决办法:删除掉driver参数--driver oracle.jdbc.driver.OracleDriver

相关推荐
远歌已逝1 小时前
维护在线重做日志(二)
数据库·oracle
JessieZeng aaa9 小时前
CSV文件数据导入hive
数据仓库·hive·hadoop
LKID体9 小时前
Python操作neo4j库py2neo使用(一)
python·oracle·neo4j
斗-匕10 小时前
Spring事务管理
数据库·spring·oracle
一行玩python10 小时前
SQLAlchemy,ORM的Python标杆!
开发语言·数据库·python·oracle
王ASC12 小时前
ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值。ojdbc8版本23.2.0.0驱动BUG【已解决】
数据库·sql·oracle
不爱学习的啊Biao13 小时前
初识mysql数据库
数据库·mysql·oracle
SRC_BLUE_1713 小时前
SQLI LABS | Less-55 GET-Challenge-Union-14 Queries Allowed-Variation 2
oracle·c#·less
Yz987615 小时前
hive复杂数据类型Array & Map & Struct & 炸裂函数explode
大数据·数据库·数据仓库·hive·hadoop·数据库开发·big data
.16 小时前
接口 测试
数据库·oracle