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

Stamatis Zampetakis commented on CALCITE-4668:
----------------------------------------------

The sub-query.iq tests in question were added as part of CALCITE-2329 targeting 
"constant IN (sub-query)" pattern. I think changing the condition to get a 
different plan no longer serves the original intention. The plans that became 
trivial had no results before the change so in terms of coverage we didn't lose 
something in the execution side. The new plan is different but it is valid and 
better than the old one so from my perspective we don't need to do something 
more. 

> RelBuilder.join should only emit a correlate when a correlate variable is used
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-4668
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4668
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: James Starr
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> We generate correlated join when no correlate variable is present on the 
> right side.  However, this could be simplified to emit a normal join.
> Given:
> {code:java}
> final RelNode rel = builder
>     .scan("EMP")
>     .variable(v)
>     .scan("DEPT")
>     .join(JoinRelType.LEFT,
>         builder.equals(builder.field(2, 0, "SAL"),
>             builder.literal(1000)),
>         ImmutableSet.of(v.get().id))
>     .build();
> {code}
> Currently the following is emitted:
> {code}
> LogicalFilter(condition=[=($7, $8)])
>   LogicalCorrelate(correlation=[$cor0], joinType=[left], 
> requiredColumns=[{0}])
>     LogicalTableScan(table=[[scott, EMP]])
>     LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
>       LogicalTableScan(table=[[scott, DEPT]])
> {code}
> After the changes the following will be emitted:
> {code}
> LogicalJoin(condition=[=($7, $8)], joinType=[left])
>   LogicalTableScan(table=[[scott, EMP]])
>   LogicalTableScan(table=[[scott, DEPT]])
> {code}



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

Reply via email to