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

Julian Hyde edited comment on CALCITE-4375 at 11/4/20, 9:46 PM:
----------------------------------------------------------------

It might be better to do the CNF rewrite only in the particular rule that is 
trying to push down. (I am always skeptical that there is a single best form 
for an expression. Especially with CNF, which can increase the size of an 
expression exponentially in the worst case.)

The rewrite might be guided by which columns come from which sides of the join.

To be clear. The method that rewrites RexNode should be in a utility such as 
RexUtil or RexSimplify (not in the particular rule), and it should be unit 
tested. But you should do the rewrite only inside the rule, and you should not 
store the "simplified" expression in Join.condition.


was (Author: julianhyde):
It might be better to do the CNF rewrite only in the particular rule that is 
trying to push down. (I am always skeptical that there is a single best form 
for an expression. Especially with CNF, which can increase the size of an 
expression exponentially in the worst case.)

The rewrite might be guided by which columns come from which sides of the join.

> Merge join condition that has "OR" as much as possible
> ------------------------------------------------------
>
>                 Key: CALCITE-4375
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4375
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Jiatao Tao
>            Assignee: Jiatao Tao
>            Priority: Major
>
> SQL:
> SELECT * FROM emps,depts 
>  WHERE
>  (emps.name = depts.name AND empno=1)
>  OR 
>  (emps.name = depts.name AND empno=2)
>  
> And the join after optimizer is:
> EnumerableNestedLoopJoin(condition=[OR(AND(=($1, $11), =($0, 1)), AND(=($1, 
> $11), =($0, 2)))], joinType=[inner])
>  
> In fact ($1, $11) can be extracted, and the join can be:
> HashJoin(condition=[AND(=($1, $11), OR(=($0, 1), =($0, 2)))], 
> joinType=[inner]) 
>  



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

Reply via email to