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

ExprNodeColumnDesc cannot be cast to ExprNodeConstantDesc

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.13.0, 0.14.0
    • None
    • None
    • None

    Description

      The following explain statement would fail in hive 0.13 and trunk
      with "ExprNodeColumnDesc cannot be cast to ExprNodeConstantDesc" exception:

      create table test.t2( key string, value int);
      explain select
         sum(u.value) value
      from test.t2 u
      group by u.key
      having sum(u.value) > 30;
      

      The full stack trace:

      java.lang.ClassCastException: org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc cannot be cast to org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc
      at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.process(TypeCheckProcFactory.java:1067)
      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:184)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genAllExprNodeDesc(SemanticAnalyzer.java:9561)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genExprNodeDesc(SemanticAnalyzer.java:9517)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genExprNodeDesc(SemanticAnalyzer.java:9488)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFilterPlan(SemanticAnalyzer.java:2314)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFilterPlan(SemanticAnalyzer.java:2295)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genHavingPlan(SemanticAnalyzer.java:2139)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPostGroupByBodyPlan(SemanticAnalyzer.java:8170)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:8133)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:8963)
      at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:9216)
      at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:327)
      at org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer.analyzeInternal(ExplainSemanticAnalyzer.java:64)
      at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:327)
      at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:422)
      at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:322)
      at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:975)
      at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1040)
      at org.apache.hadoop.hive.ql.Driver.run(Driver.java:911)
      at org.apache.hadoop.hive.ql.Driver.run(Driver.java:901)
      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:423)
      at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:792)
      at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
      at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
      

      I think it's due to HIVE-3107. HIVE-3107 introduces alternate mapping for a column in RowResolver. While mapping the having clause in TypeCheckProcFactory, it first maps "value" to col_1(output of groupby clause) which has type of ExprNodeColumnDesc (Before HIVE-3107, "value" is not recognized). When it comes to "u.value", it finds that "u" is a table alias but fails to cast nodeOutputs[1] to ExprNodeConstantDesc.
      Here I think we can use the text attribute in the expr node as colAlias instead.

      Attachments

        1. HIVE-8398.2.patch
          1 kB
          Zhichun Wu
        2. HIVE-8398.patch
          1 kB
          Zhichun Wu

        Issue Links

          Activity

            People

              akshaygoyal Akshay Goyal
              wzc1989 Zhichun Wu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: