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

Julian Hyde reassigned CALCITE-4711:
------------------------------------

    Assignee: Julian Hyde

> RexProgramBuilder should not simplify
> -------------------------------------
>
>                 Key: CALCITE-4711
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4711
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>
> {{RexProgramBuilder}} currently simplifies expressions even if no 
> {{RexSimplifier}} instance is supplied in its constructor: the method 
> {{registerInternal}} creates a {{RexSimplifier}}.
> This simplification used to be beneficial. For instance, as of 
> [4ef9f467|https://github.com/apache/calcite/commits/4ef9f46757528d21c510eb8bd171fa04ba86e36d],
>  {{RexProgramBuilder}} can simplify "x AND y AND x" to "x AND y". But now we 
> have RexSimplifier, which is applied pretty much any time a RexNode is 
> included in a RelNode via a RelBuilder method.
> Simplify is now called in too many places, and I suspect that the running 
> time is multiplying. Consider: {{RexSimplify.simplifyCast}} calls 
> {{RexExecutor.reduce}} to reduce constants. To do this, {{RexExecutor}} uses 
> {{RexProgramBuilder}} to generate a program (which will then be executed to 
> yield the reduced value), and the RexProgramBuilder calls simplify again. It 
> is ridiculous to call simplify at so many levels. It's time that we reduced 
> the responsibilities of {{RexProgramBuilder}} to just building programs.
> (It is possible that, once a {{RexProgram}} has been created, we can see some 
> patterns in the flattened expressions that would not be apparent to 
> {{RexSimplify}}. If this happens, we could have a simplify step that works on 
> {{Calc}} after its program has been generated.)
> After this change, {{RexProgramBuilder}} will simplify only if a 
> {{RexSimplify}} is passed in the constructor. {{RexProgramBuilder}} will no 
> longer be able to simplify "x AND y AND x". We will add a test to ensure that 
> {{RelBuilder.filter}} can do this.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to