在hive新建一张表:
create table ods.ods_com_userNum(? ?? ?yearid string,monthid string, ?? ?qiye string comment 'qiye',? ?? ?chizhengNum int comment '持证人数', ?? ?qianyueNum ?int comment '签约人数', ?? ?date_insert ?string comment '数据入仓库时间'? ) ROW FORMAT DELIMITED FIELDS TERMINATED BY '^' STORED AS TEXTFILE;
?
从mysql把数据导入到hive
sqoop导入语句:
sqoop import \ --connect 'jdbc:mysql://192.168.1.12:3306/test?serverTimezone=Asia/Shanghai' \ --username readuser --password 'readuser' \ --target-dir ?/warehouse/tablespace/managed/hive/ods.db/ods_com_userNum \ --delete-target-dir \ --query "select yearid, monthid, corpcode, chizhengNum,qianyueNum ,now() from test.usernum where 1=1 and \$CONDITIONS " \ --null-string '\\N' ?--null-non-string '\\N' \ --hive-drop-import-delims --fields-terminated-by '^' -m 1
现象
导入结果:接入成功
查询hive:查询结果为空
原因:
路径:/warehouse/tablespace/managed/hive/ods.db/ods_com_userNum
改为:/warehouse/tablespace/managed/hive/ods.db/ods_com_usernum
|