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

Zhen Chen commented on CALCITE-7071:
------------------------------------

I found that FilterIntoJoinRule will simplify the JOIN condition. If the 
condition is always false, the corresponding child node will be replaced with 
empty VALUES ​​according to the JOIN type. Later, in PruneEmptyRules, the JOIN 
will be eliminated according to the JOIN type (LEFT JOIN or RIGHT JOIN). This 
capability is indirectly implemented through these two rules. It may not be 
necessary to implement a new rule. The current jira description is also a 
scenario that can eliminate OUTER JOIN. Although it cannot cover all scenarios, 
it can play a certain role. So I would like to ask if it is necessary to modify 
the logic as described in the jira?

> Support replacing JOIN node with its child node when JOIN condition is false 
> in ProjectJoinRemoveRule
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7071
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7071
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Zhen Chen
>            Assignee: Zhen Chen
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.41.0
>
>
> SQL
> {code:java}
> SELECT e.deptno
> FROM sales.emp e
> LEFT JOIN sales.dept d ON e.deptno = d.deptno and e.deptno between 3 and 1
> {code}
> Plan before
> {code:java}
> LogicalProject(DEPTNO=[$7])
>   LogicalJoin(condition=[false], joinType=[left])
>     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
> {code}
> Plan after
> {code:java}
> LogicalProject(DEPTNO=[$7])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> In ProjectJoinRemoveRule, when the Join condition is false, replace the Join 
> with its left child for a left join or its right child for a right join. The 
> above is an example of a left join.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to