sqoop export:java.lang.RuntimeException: Can't parse input data

使用sqoop从hive导出数据到mysql发生如下错误:
sqoop export –connect jdbc:mysql://192.168.38.64:3306/test –username root -P –table mytable –input-null-string ‘\N’ –export-dir /user/hive/warehouse/test.db/mytable

Error: java.io.IOException: Can't export data, please check failed map task logs
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:112)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:39)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1614)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
Caused by: java.lang.RuntimeException: Can't parse input data: '1kevin17'
at mytable.__loadFromFields(mytable.java:292)
at mytable.parse(mytable.java:230)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:83)
... 10 more
Caused by: java.lang.NumberFormatException: For input string: "1kevin17"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.valueOf(Integer.java:582)
at mytable.__loadFromFields(mytable.java:279)
... 12 mor

这是因为 没有指定null字段分隔符,导致错位。

sqoop export –connect jdbc:mysql://192.168.38.64:3306/test –username root -P –table mytable –input-null-string ‘\N’ –input-null-non-string ‘\N’ –input-fields-terminated-by ‘\001’ –export-dir /user/hive/warehouse/test.db/mytable

测试成功。

你可能感兴趣的:(大数据)