You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2016/07/07 20:57:11 UTC

[jira] [Resolved] (CALCITE-1295) ReduceExpressionRule should not reduce AS operator

     [ https://issues.apache.org/jira/browse/CALCITE-1295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-1295.
----------------------------------
    Resolution: Invalid

I only just noticed that you are calling {{LogicalProject.create}}. It's reasonable that {{RelBuilder.project}} should strip {{AS}} calls out of expressions, but I don't think {{LogicalProject.create}} should do that. There's no good reason to have AS calls in RexNode trees once the SQL has been translated and column names have been determined.

In summary, I don't think this is a bug in {{ReduceExpressionRule}}, it's a bug in your code. If you want {{AS}} to be stripped out, call {{RelBuilder.project}} rather than {{LogicalProject.create}}.

Closing as invalid.

> ReduceExpressionRule should not reduce AS operator
> --------------------------------------------------
>
>                 Key: CALCITE-1295
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1295
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.8.0
>            Reporter: Jark Wu
>            Assignee: Julian Hyde
>            Priority: Minor
>             Fix For: 1.8.0, 1.9.0
>
>
> In extremely rare cases, if we build relation tree ourselves through RelBuilder. 
> {code:java}
> relBuilder.push(
>         LogicalProject.create(relBuilder.peek(),
>           Lists.newArrayList(relBuilder.alias(relBuilder.literal(true), "_c0")),
>           Lists.newArrayList("_c0")))
> {code}
> 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 : 
> {code:java}
> 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)
> {{code}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)