[ 
https://issues.apache.org/jira/browse/CALCITE-2295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-2295:
------------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Priority: Critical
>              Labels: pull-request-available
>
> 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
(v8.20.10#820010)

Reply via email to