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

Decorrelation for join with lateral table outputs wrong plan if the join condition contains correlation variables

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.22.0
    • 1.23.0
    • core

    Description

      After CALCITE-2004, we can decorrelate plan for query:

      select deptno, r.num from dept join
      lateral table(ramp(dept.deptno)) as r(num)
      on deptno=num
      

      to plan like:

      LogicalProject(DEPTNO=[$0], NUM=[$2])
        LogicalJoin(condition=[=($0, $2)], joinType=[inner])
          LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
          LogicalTableFunctionScan(invocation=[RAMP($cor0.DEPTNO)], rowType=[RecordType(INTEGER I)])
      

      See there was a correlate variable left.

      To fix this, i would suggest to stop decorrelating when we encounter the correlate variables in LogicalTableFunctionScan.

      Attachments

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              danny0405 Danny Chen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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