具有ToDate内置函数的PIg-NullPointerException

时间:2014-03-20 09:05:06

标签: hadoop jodatime bigdata apache-pig

我的Pig内置函数ToDate有问题。

我有一个名为result2的变量,它具有以下格式:

{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;

字段DATE_HADO和DAT_START如下所示:

(2014/03/10 00:00:00)
(2014/03/10 00:00:01)
(2014/03/10 00:00:00)

当我执行代码时,会引发此异常:

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)

我不明白,我的代码似乎很好,但它不起作用。

你知道为什么吗?

由于

1 个答案:

答案 0 :(得分:1)

您的某些日期字段可能为空。检查它们是否为空,否则会出现NullpointerException。此外,日期模式应为yyyy/MM/dd HH:mm:ss,当月有两个大写字母。