pig-nullpointerexception和todate内置函数

sqougxex  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(455)

我对pig的内置函数有个问题。
我有一个名为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\u hado和dat\u 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)

我不明白,我的代码似乎很好,但它不工作。
你知道为什么吗?
谢谢

jm81lzqq

jm81lzqq1#

某些日期字段可能为空。首先检查它们是否为null,否则会得到nullpointerexception。另外,日期模式应该是 yyyy/MM/dd HH:mm:ss 月份用两个大写字母m。

相关问题