Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1295

ReduceExpressionRule should not reduce AS operator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Invalid
    • 1.8.0
    • 1.9.0
    • core
    • None
    • Patch

    Description

      In extremely rare cases, if we build relation tree ourselves through RelBuilder.

      relBuilder.push(
              LogicalProject.create(relBuilder.peek(),
                Lists.newArrayList(relBuilder.alias(relBuilder.literal(true), "_c0")),
                Lists.newArrayList("_c0")))
      

      Then we may have AS(true, $1) in the expressions, and AS(true, $1) can satisfy ReduceExpressionRule, but AS call do not exist in RexImpTable.INSTANCE, so it throws this :

      java.lang.RuntimeException: cannot translate call AS($t0, $t1)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateCall(RexToLixTranslator.java:533)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate0(RexToLixTranslator.java:507)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:219)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate0(RexToLixTranslator.java:472)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:219)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:214)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateList(RexToLixTranslator.java:700)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateProjects(RexToLixTranslator.java:189)
      	at org.apache.calcite.rex.RexExecutorImpl.compile(RexExecutorImpl.java:80)
      	at org.apache.calcite.rex.RexExecutorImpl.compile(RexExecutorImpl.java:59)
      	at org.apache.calcite.rex.RexExecutorImpl.reduce(RexExecutorImpl.java:118)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressionsInternal(ReduceExpressionsRule.java:544)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions(ReduceExpressionsRule.java:455)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions(ReduceExpressionsRule.java:438)
      {

      }

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            jark Jark Wu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: