解决sqoop报错Invalid number; item = ITEM_UNICODE

时间:2023-01-08 04:07:13

报错栈:

java.sql.SQLException: Invalid number; item = ITEM_UNICODE
at com.intersys.jdbc.SysList.getInt(SysList.java:)
at com.intersys.jdbc.CacheResultSet.getInt(CacheResultSet.java:)
at org.apache.sqoop.lib.JdbcWritableBridge.readInteger(JdbcWritableBridge.java:)
at com.cloudera.sqoop.lib.JdbcWritableBridge.readInteger(JdbcWritableBridge.java:)
at QueryResult.readFields(QueryResult.java:)
at org.apache.sqoop.mapreduce.db.DBRecordReader.nextKeyValue(DBRecordReader.java:)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:)
at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:)
at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
at org.apache.hadoop.mapred.YarnChild$.run(YarnChild.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:)

问题的根本原因是字段值类型异常,本来应该是数字型,里面却存了unicode字符。使用报错信息查不到相关资料,另外增加参数也不能解决:-D mapreduce.map.failures.maxpercent=1, query里面增加: and Specimen is not null 也不能解决。(Specimen是报错字段)。

靠谱的解决办法是找出这行异常数据,在数据库中纠正或删除。如果想临时解决,可以把这个字段在导入时转换类型为字符:--map-column-java Specimen=String。