Some of your date fields are probably null. Check if they are null first, otherwise you get a NullpointerException. Also, the date pattern should be yyyy/MM/dd HH:mm:ss
with two capital m for the month.
PIg- NullPointerException with ToDate built-in function
-
17-06-2023 - |
سؤال
I have a problem with Pig's built-in function ToDate.
I have a variable named result2, which has this format:
{search_file::DATE_HADO: chararray,search_file::IP: chararray,A::COD_IP: chararray,A::DAT_START: chararray,A::NDI_START: chararray}
argl = foreach result2 GENERATE ToDate(DATE_HADO,'yyyy/mm/dd HH:mm:ss'), IP, COD_IP, ToDate(DAT_START,'yyyy/mm/dd HH:mm:ss'), NDI_START;
dump argl;
the fields DATE_HADO and DAT_START looks like this:
(2014/03/10 00:00:00)
(2014/03/10 00:00:01)
(2014/03/10 00:00:00)
When I execute the code, this exception is raised:
java.lang.NullPointerException
at org.joda.time.format.DateTimeFormatterBuilder$NumberFormatter.parseInto(DateTimeFormatterBuilder.java:1200)
at org.joda.time.format.DateTimeFormatterBuilder$Composite.parseInto(DateTimeFormatterBuilder.java:2525)
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:669)
at org.apache.pig.builtin.ToDate2ARGS.exec(ToDate2ARGS.java:42)
at org.apache.pig.builtin.ToDate2ARGS.exec(ToDate2ARGS.java:33)
at org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc.getNext(POUserFunc.java:337)
at org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc.getNext(POUserFunc.java:422)
at org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator.getNext(PhysicalOperator.java:350)
at org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach.processPlan(POForEach.java:372)
at org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach.getNext(POForEach.java:297)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.runPipeline(PigGenericMapReduce.java:465)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.processOnePackageOutput(PigGenericMapReduce.java:433)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.reduce(PigGenericMapReduce.java:413)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.reduce(PigGenericMapReduce.java:257)
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:164)
at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:610)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:444)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:449)
I don't understand, My code seems to be good but it doesn't work.
Do you know why ?
Thanks
المحلول
لا تنتمي إلى StackOverflow