Hive
  1. Hive
  2. HIVE-6704

date_add()/date_sub()/datediff() fail with NPE with null input

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.13.0
    • Component/s: UDF
    • Labels:
      None

      Description

      Similar to HIVE-6645, the following functions also get NPE error if the input is null:
      date_add
      date_sub
      datediff

      Diagnostic Messages for this Task:
      Error: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"t":null,"si":null,"i":null,"b":null,"f":null,"d":null,"dc":null,"bo":null,"s":null,"s2":null,"ts":null,"ts2":null,"dt":null}
      	at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:195)
      	at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
      	at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
      	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
      	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:415)
      	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548)
      	at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
      Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"t":null,"si":null,"i":null,"b":null,"f":null,"d":null,"dc":null,"bo":null,"s":null,"s2":null,"ts":null,"ts2":null,"dt":null}
      	at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:534)
      	at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:177)
      	... 8 more
      Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating date_add(ts, 2)
      	at org.apache.hadoop.hive.ql.exec.SelectOperator.processOp(SelectOperator.java:84)
      	at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:791)
      	at org.apache.hadoop.hive.ql.exec.TableScanOperator.processOp(TableScanOperator.java:92)
      	at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:791)
      	at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:524)
      	... 9 more
      Caused by: java.lang.NullPointerException
      	at org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateAdd.evaluate(GenericUDFDateAdd.java:144)
      	at org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
      	at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
      	at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:65)
      	at org.apache.hadoop.hive.ql.exec.SelectOperator.processOp(SelectOperator.java:79)
      	... 13 more
      
      
      FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
      

        Issue Links

          Activity

          Hide
          Jason Dere added a comment -

          RB at https://reviews.apache.org/r/19447/
          Also this patch adds support for char/varchar argument types.

          Show
          Jason Dere added a comment - RB at https://reviews.apache.org/r/19447/ Also this patch adds support for char/varchar argument types.
          Hide
          Ashutosh Chauhan added a comment -

          +1

          Show
          Ashutosh Chauhan added a comment - +1
          Hide
          Hive QA added a comment -

          Overall: -1 at least one tests failed

          Here are the results of testing the latest attachment:
          https://issues.apache.org/jira/secure/attachment/12635713/HIVE-6704.1.patch

          ERROR: -1 due to 2 failed/errored test(s), 5440 tests executed
          Failed tests:

          org.apache.hadoop.hive.cli.TestMinimrCliDriver.testCliDriver_bucket_num_reducers
          org.apache.hadoop.hive.cli.TestMinimrCliDriver.testCliDriver_disable_merge_for_bucketing
          

          Test results: http://bigtop01.cloudera.org:8080/job/PreCommit-HIVE-Build/1916/testReport
          Console output: http://bigtop01.cloudera.org:8080/job/PreCommit-HIVE-Build/1916/console

          Messages:

          Executing org.apache.hive.ptest.execution.PrepPhase
          Executing org.apache.hive.ptest.execution.ExecutionPhase
          Executing org.apache.hive.ptest.execution.ReportingPhase
          Tests exited with: TestsFailedException: 2 tests failed
          

          This message is automatically generated.

          ATTACHMENT ID: 12635713

          Show
          Hive QA added a comment - Overall : -1 at least one tests failed Here are the results of testing the latest attachment: https://issues.apache.org/jira/secure/attachment/12635713/HIVE-6704.1.patch ERROR: -1 due to 2 failed/errored test(s), 5440 tests executed Failed tests: org.apache.hadoop.hive.cli.TestMinimrCliDriver.testCliDriver_bucket_num_reducers org.apache.hadoop.hive.cli.TestMinimrCliDriver.testCliDriver_disable_merge_for_bucketing Test results: http://bigtop01.cloudera.org:8080/job/PreCommit-HIVE-Build/1916/testReport Console output: http://bigtop01.cloudera.org:8080/job/PreCommit-HIVE-Build/1916/console Messages: Executing org.apache.hive.ptest.execution.PrepPhase Executing org.apache.hive.ptest.execution.ExecutionPhase Executing org.apache.hive.ptest.execution.ReportingPhase Tests exited with: TestsFailedException: 2 tests failed This message is automatically generated. ATTACHMENT ID: 12635713
          Hide
          Ashutosh Chauhan added a comment -

          Committed to trunk & 0.13 Thanks, Jason!

          Show
          Ashutosh Chauhan added a comment - Committed to trunk & 0.13 Thanks, Jason!

            People

            • Assignee:
              Jason Dere
              Reporter:
              Jason Dere
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development