Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-5656

Hive produces unclear, confusing SemanticException when dealing with mod or pmod by zero

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.12.0
    • 0.13.0
    • Types
    • None

    Description

      hive> select 5%0 from tmp2 limit 1;
      FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments '0': org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.io.IntWritable org.apache.hadoop.hive.ql.udf.UDFOPMod.evaluate(org.apache.hadoop.io.IntWritable,org.apache.hadoop.io.IntWritable)  on object org.apache.hadoop.hive.ql.udf.UDFOPMod@21b594a9 of class org.apache.hadoop.hive.ql.udf.UDFOPMod with arguments {5:org.apache.hadoop.io.IntWritable, 0:org.apache.hadoop.io.IntWritable} of size 2
      
      hive> select pmod(5,0) from tmp2 limit 1;
      FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments '0': org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.io.IntWritable org.apache.hadoop.hive.ql.udf.UDFPosMod.evaluate(org.apache.hadoop.io.IntWritable,org.apache.hadoop.io.IntWritable)  on object org.apache.hadoop.hive.ql.udf.UDFPosMod@174ed99a of class org.apache.hadoop.hive.ql.udf.UDFPosMod with arguments {5:org.apache.hadoop.io.IntWritable, 0:org.apache.hadoop.io.IntWritable} of size 2
      

      Exception stack:

              at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.process(TypeCheckProcFactory.java:1112)
              at org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher.dispatch(DefaultRuleDispatcher.java:90)
              at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatchAndReturn(DefaultGraphWalker.java:94)
              at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatch(DefaultGraphWalker.java:78)
              at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.walk(DefaultGraphWalker.java:132)
              at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.startWalking(DefaultGraphWalker.java:109)
              at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory.genExprNode(TypeCheckProcFactory.java:181)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genAllExprNodeDesc(SemanticAnalyzer.java:8870)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genExprNodeDesc(SemanticAnalyzer.java:8826)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genSelectPlan(SemanticAnalyzer.java:2734)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genSelectPlan(SemanticAnalyzer.java:2531)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPostGroupByBodyPlan(SemanticAnalyzer.java:7606)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:7562)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:8365)
              at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:8591)
              at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:284)
              at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:451)
              at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:351)
              at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1004)
              at org.apache.hadoop.hive.ql.Driver.run(Driver.java:915)
              at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
              at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
              at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:422)
              at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:790)
              at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:684)
              at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:623)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:601)
              at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
      

      The correct behaviour should be producing NULL.

      Attachments

        1. HIVE-5656.patch
          215 kB
          Xuefu Zhang

        Issue Links

          Activity

            People

              xuefuz Xuefu Zhang
              xuefuz Xuefu Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: