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

Vineet Garg commented on CALCITE-2295:
--------------------------------------

[~julianhyde] Does *SqlToRelConverter* not support correlated subquery in 
project? I looked at code *SqlToRelConverter::convertSelectList* and I don't 
see Calcite handling case for correlation subquery expressions.

> Correlated SubQuery with Project will generate error plan
> ---------------------------------------------------------
>
>                 Key: CALCITE-2295
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2295
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.15.0
>            Reporter: godfrey he
>            Assignee: Julian Hyde
>            Priority: Critical
>
> test case in *RelOptRulesTest.java*:
> {code:java}
> @Test public void testDecorrelateWithProject() throws Exception {
>     final String sql = "select sal,\n"
>                        + "exists (select * from emp_b where emp.deptno = 
> emp_b.deptno)\n"
>                        + "from sales.emp";
>     checkSubQuery(sql).withLateDecorrelation(true).check();
> }
> {code}
> after *SqlToRelConverter*, the plan is
> {code:java}
> LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
> LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
> })])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> NOTES: *LogicalProject* does not have any *_variablesSet_* attributes.
> the correct plan should be:
> {code:java}
> LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
> LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
> })], variablesSet=[[$cor0]])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to