Sqoop导出到SQL服务器 - 无法解析字符串值(NTL-NATIONAL)

时间:2016-09-01 05:50:57

标签: sql-server hadoop hive sqoop

我正在尝试使用Sqoop导出Hive表到SQL服务器。我在hive表中有一个字符串字段,SQL服务器中该字段的格式是varchar(255)。在运行以下Sqoop导出时:

sqoop export -Dmapreduce.job.queuename=default
 --connect 'jdbc:sqlserver://IPaddress:portnumber;databasename=mydbname'
 --username xxx 
 --password  xxx 
 --table tablename 
 --export-dir /hive_directory/tablename 
 --columns all_my_columns 
 --input-fields-terminated-by '^' 
 --input-null-string "\\\\N" --input-null-non-string "\\\\N" 

我得到以下错误。字段值类似于...... NTL-NATIONAL。感谢任何解析这个值的想法。谢谢。

INFO mapreduce.Job: Task Id : attempt_1468858380028_769962_m_000002_0, Status : FAILED
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:146)
        at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        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:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
Caused by: java.lang.RuntimeException: Can't parse input data: 'NTL-NATIONAL'
        at test_fnl.__loadFromFields(test_fnl.java:1109)
        at test_fnl.parse(test_fnl.java:952)
        at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:83)
        ... 10 more
Caused by: java.util.NoSuchElementException
        at java.util.ArrayList$Itr.next(ArrayList.java:854)
        at test_fnl.__loadFromFields(test_fnl.java:1104)
        ... 12 more

1 个答案:

答案 0 :(得分:0)

你试过包含这个论点吗?

--input-lines-terminated-by <char>

--input-lines-terminated-by '\n'