[ 
https://issues.apache.org/jira/browse/CALCITE-2041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244311#comment-16244311
 ] 

slim bouguerra commented on CALCITE-2041:
-----------------------------------------

Trying to add some testing to class {code} 
org.apache.calcite.rel.rules.ReduceExpressionsRule#FILTER_INSTANCE {code} part 
of {code} 
org.apache.calcite.prepare.CalcitePrepareImpl#CONSTANT_REDUCTION_RULES {code}
but looking at the code base i can see that the only use of such rule is 
excluded via this  block at 
org/apache/calcite/prepare/CalcitePrepareImpl.java:571 git hash 
221739354b56e34e9f1d41b42a0e6881a8f5ddee
{code} 
// Change the below to enable constant-reduction.
    if (false) {
      for (RelOptRule rule : CONSTANT_REDUCTION_RULES) {
        planner.addRule(rule);
      }
    }
{code}
while the comment says it is enabling constant reductions I can not see how 
this is done since the block is never executed? not sure what is the idea of 
keeping such code with {code} if (false) {code}.
Not sure what is the best way to test such rule since it is excluded from 
planer anyway.



> Adding the ability to turn off nullability matching for ReduceExpressionsRule
> -----------------------------------------------------------------------------
>
>                 Key: CALCITE-2041
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2041
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: slim bouguerra
>            Assignee: Julian Hyde
>
> In some cases, the user needs to select whether or not to add casts that 
> match nullability.
> One of the motivations behind this is to avoid unnecessary casts like the 
> following example.
> original filter 
> {code}
> OR(AND(>=($0, CAST(_UTF-16LE'2010-01-01 00:00:00 
> UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15)), <=($0, CAST(_UTF-16LE'2012-03-01 
> 00:00:00 UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15))))
> {code}
> the optimized expression with matching nullability
> {code}
> OR(AND(CAST(>=($0, 2010-01-01 00:00:00)):BOOLEAN, CAST(<=($0, 2012-03-01 
> 00:00:00)):BOOLEAN))
> {code}
> As you can see this extra cast gets into the way of following plan 
> optimization steps.
> The desired expression can be obtained by turning off the nullability 
> matching.
> {code}
> OR(AND(>=($0, 2010-01-01 00:00:00), <=($0, 2012-03-01 00:00:00)))
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to