在执行sqoop命令将mysql中的映射表更新至大数据环境中出现了如下所示的问题
执行的sqoop代码如下图所示
sqoop import \
--connect jdbc:mysql://172.19.131.98:13306/jg_bigdata \
--username hlwjg \
--password hlw+JG@2hb \
--table jg_org_inf_tbl \
--delete-target-dir \
-m 1 \
--hive-overwrite \
--hive-import \
--null-string '\\N' \
--null-non-string '\\N' \
--target-dir /warehouse/tablespace/external/hive/tmpdb.db/jg_org_inf_tbl_tmp1 \
--hive-database global \
--hive-table jg_org_inf_tbl_tmp1 \
--hive-drop-import-delims
后来排查日志发现有这么一行
Error: Error while compiling statement: FAILED: SemanticException Unable to load data to destination table. Error: The file that you are trying to load does not match the file format of the destination table. (state=42000,code=40000)
说的是尝试加载的文件与目标表的文件格式不匹配
查看发现原来我的hive目标表是orc存储格式的,不支持load方式导入数据,因为sqoop本质上是load导入数据的方式,所以会出错
解决办法
1,新建一个存储格式为textfile的临时表
create table global.jg_org_inf_tbl_tmp1
(id string comment'主键'
,xxxxxx string comment'xxxxx')
stored as textFile TBLPROPERTIES ('transactional'='false');
2,将数据导入临时表中
3,通过查询插入的方式将临时表数据导入目标表
insert into global.jg_org_inf_tbl select * from global.jg_org_inf_tbl_tmp1