Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2295

Correlated SubQuery with Project will generate error plan

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 1.15.0
    • None
    • core
    • None

    Description

      test case in RelOptRulesTest.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();
      }
      

      after SqlToRelConverter, the plan is

      LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
      LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
      })])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      NOTES: LogicalProject does not have any variablesSet attributes.

      the correct plan should be:

      LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
      LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
      })], variablesSet=[[$cor0]])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            godfreyhe godfrey he
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: