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

Julian Hyde commented on CALCITE-3431:
--------------------------------------

The word "natural" in the description confused me. You're not talking about 
"natural join" here.

Yes it makes sense to have a variant of SemiJoinRule that looks for uniqueness 
not an Aggregate per se. However, you will need to be careful that the rule 
doesn't cycle.

Also make sure that people can opt out of this functionality. Based on 
discussions on the mail list, not everyone considers it useful to merely 
convert join -> semiJoin if no other RelNodes are removed.

> SemiJoinRule doesn't work when right-hand side is natural distinct on join 
> keys
> -------------------------------------------------------------------------------
>
>                 Key: CALCITE-3431
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3431
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: jin xing
>            Assignee: jin xing
>            Priority: Major
>
> Calcite generate semi-join by SemiJoinRule, which only works on pattern of 
> Join(RelNode, Aggregate).
> Take below sql as an example 
> {code:java}
>  select * from dept 
>  where exists (
>   select * from emp
>   where emp.empno = dept.deptno)
> {code}
> If empno is a key column of emp, thus the original plan is as below
> {code:java}
> LogicalProject(DEPTNO=[$0], NAME=[$1])
>   LogicalJoin(condition=[=($0, $2)], joinType=[inner])
>     LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
>     LogicalProject(EMPNO=[$0])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> Thus SemiJoinRule cannot support such a pattern
>  
>  



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

Reply via email to