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

Nested Queries are not expanded properly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      SubQueryRemoveRule does not expand the subqueries correctly:

      SELECT deptno
      FROM emp e
      WHERE EXISTS (
        SELECT *
        FROM dept d
        WHERE d.deptno = e.deptno
          AND exists(
            SELECT *
            FROM emp_address ea
            WHERE ea.empno = e.empno)
          AND exists(
            SELECT *
            FROM emp e2
            WHERE e2.deptno = d.deptno))

       

      LogicalProject(DEPTNO=[$7])
        LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0, 7}])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
          LogicalAggregate(group=[{0}])
            LogicalProject(i=[true])
              LogicalFilter(condition=[=($0, $cor0.DEPTNO)])
                LogicalCorrelate(correlation=[$cor2], joinType=[inner], requiredColumns=[{0}])
                  LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}]) <--- This is incorrect.
                    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
                    LogicalAggregate(group=[{0}])
                      LogicalProject(i=[true])
                        LogicalFilter(condition=[=($0, $cor0.EMPNO)])
                          LogicalTableScan(table=[[CATALOG, SALES, EMP_ADDRESS]])
                  LogicalAggregate(group=[{0}])
                    LogicalProject(i=[true])
                      LogicalFilter(condition=[=($7, $cor2.DEPTNO)])
                        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jamesstarr James Starr
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m