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.
- links to