Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-4716

Expr rewrite causes IllegalStateException

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Impala 2.8.0
    • Fix Version/s: Impala 2.9.0
    • Component/s: Frontend
    • Labels:

      Description

      The query: 'select decode(0, 1, 1, id, 1) from functional.alltypessmall;' works as expected with enable_expr_rewrites=false, but with rewrites enabled gives:

      ERROR: AnalysisException: null
      CAUSED BY: IllegalStateException: child 0 type: INT child 1 type: TINYINT

      Caused by: java.lang.IllegalStateException: child 0 type: INT child 1 type: TINYINT
      at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
      at org.apache.impala.analysis.BinaryPredicate.toThrift(BinaryPredicate.java:155)
      at org.apache.impala.analysis.Expr.treeToThriftHelper(Expr.java:529)
      at org.apache.impala.analysis.Expr.treeToThrift(Expr.java:511)
      at org.apache.impala.service.FeSupport.EvalExprWithoutRow(FeSupport.java:126)
      at org.apache.impala.analysis.LiteralExpr.create(LiteralExpr.java:173)
      at org.apache.impala.rewrite.FoldConstantsRule.apply(FoldConstantsRule.java:56)
      at org.apache.impala.rewrite.ExprRewriter.applyRuleBottomUp(ExprRewriter.java:85)
      at org.apache.impala.rewrite.ExprRewriter.applyRuleBottomUp(ExprRewriter.java:83)
      at org.apache.impala.rewrite.ExprRewriter.applyRuleRepeatedly(ExprRewriter.java:71)
      at org.apache.impala.rewrite.ExprRewriter.rewrite(ExprRewriter.java:55)
      at org.apache.impala.analysis.SelectList.rewriteExprs(SelectList.java:93)
      at org.apache.impala.analysis.SelectStmt.rewriteExprs(SelectStmt.java:886)
      at org.apache.impala.analysis.AnalysisContext.analyze(AnalysisContext.java:388)
      ... 4 more

        Activity

        Hide
        twmarshall Thomas Tauber-Marshall added a comment -

        commit 89a3d3c1ebf85629bb20457a9672d71fbf2504ca
        Author: Thomas Tauber-Marshall <tmarshall@cloudera.com>
        Date: Thu Jan 5 16:15:32 2017 -0800

        IMPALA-4716: Expr rewrite causes IllegalStateException

        The DECODE constructor in CaseExpr uses the same decodeExpr object when
        building the BinaryPredicates that compare the decodeExpr to each 'when'
        of the DECODE. This causes problems when different BinaryPredicates try
        to cast the same decodeExpr object to different types during analysis,
        in this case leading to a Precondition check failure.

        The solution is to clone the decodeExpr in the DECODE constructor in
        CaseExpr for each generated BinaryPredicate.

        Testing:

        • Added a regression test to exprs.test

        Change-Id: I4de9ed7118c8d18ec3f02ff74c9cca211c716e51
        Reviewed-on: http://gerrit.cloudera.org:8080/5631
        Reviewed-by: Marcel Kornacker <marcel@cloudera.com>
        Tested-by: Impala Public Jenkins

        Show
        twmarshall Thomas Tauber-Marshall added a comment - commit 89a3d3c1ebf85629bb20457a9672d71fbf2504ca Author: Thomas Tauber-Marshall <tmarshall@cloudera.com> Date: Thu Jan 5 16:15:32 2017 -0800 IMPALA-4716 : Expr rewrite causes IllegalStateException The DECODE constructor in CaseExpr uses the same decodeExpr object when building the BinaryPredicates that compare the decodeExpr to each 'when' of the DECODE. This causes problems when different BinaryPredicates try to cast the same decodeExpr object to different types during analysis, in this case leading to a Precondition check failure. The solution is to clone the decodeExpr in the DECODE constructor in CaseExpr for each generated BinaryPredicate. Testing: Added a regression test to exprs.test Change-Id: I4de9ed7118c8d18ec3f02ff74c9cca211c716e51 Reviewed-on: http://gerrit.cloudera.org:8080/5631 Reviewed-by: Marcel Kornacker <marcel@cloudera.com> Tested-by: Impala Public Jenkins

          People

          • Assignee:
            twmarshall Thomas Tauber-Marshall
            Reporter:
            twmarshall Thomas Tauber-Marshall
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development