In line of
SqoopOptions.java#L785
with
{{SqoopJsonUtil.getJsonStringforMap((Map) f.get(this))); }}
Above line should check NULL pointer like in line of
SqoopOptions.java#L778
which has
f.get(this) == null ? "null" : f.get(this).toString()
Please see the stacktrace below when running command:
sqoop job --create myjob – import --connect jdbc:mysql://localhost/db --username root --table employee --m 1
19/02/02 01:09:21 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException
java.lang.NullPointerException
at org.json.JSONObject.<init>(JSONObject.java:144)
at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43)
at org.apache.sqoop.SqoopOptions.writeProperties(SqoopOptions.java:785)
at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.createInternal(HsqldbJobStorage.java:399)
at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.create(HsqldbJobStorage.java:379)
at org.apache.sqoop.tool.JobTool.createJob(JobTool.java:181)
at org.apache.sqoop.tool.JobTool.run(JobTool.java:294)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
The above
NullPointerException
is due to use the of
com.tdunning
as part of the HIVE libs (if one is reusing the
HADOOP_CLASSPATH
) in the classpath. but I think we can better have a checker of
null
in
SqoopJsonUtil.getJsonStringforMap(Map<String, String> map)
before calling
JSONObject pathPartMap = new JSONObject(map);
Reporting this bug and the right behavior need to be decided by the assignee.