sqoop中,如果数据中本身有换行符,会导致数据错位
sqoop中,如果数据中本身有换行符,会导致数据错位;
解决办法:
在sqoop import时修改配置文件
sudo -u hive sqoop import --connect jdbc:mysql://${miguanMysqlHost}/${miguanDatabaseName} --username ${miguanMysqlUser} --password ${miguanMysqlPwd} --table applibrary --hive-import --hive-table ${hiveDBName}.applibrary --hive-drop-import-delims --fields-terminated-by '\001' --lines-terminated-by '\n' --hive-overwrite
添加了:
--hive-drop-import-delims --lines-terminated-by '\n'
--hive-drop-import-delims 的意思是指:delims Drops \n, \r, and \01 from string fields when importing to Hive.
delims |
Drops \n, \r, and \01 from string fields when importing to Hive. |