Package org.apache.calcite.sql2rel
Class CorrelateProjectExtractor
java.lang.Object
org.apache.calcite.rel.RelShuttleImpl
org.apache.calcite.rel.RelHomogeneousShuttle
org.apache.calcite.sql2rel.CorrelateProjectExtractor
- All Implemented Interfaces:
RelShuttle
@API(since="1.27",
status=EXPERIMENTAL)
public final class CorrelateProjectExtractor
extends RelHomogeneousShuttle
A visitor for relational expressions that extracts a
Project
, with a "simple" computation over
the correlated variables, from the right side of a correlation
(Correlate
) and places it on the left
side.
Plan before
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}]) LogicalTableScan(table=[[scott, EMP]]) LogicalFilter(condition=[=($0, +(10, $cor0.DEPTNO))]) LogicalTableScan(table=[[scott, DEPT]])
Plan after
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3],... DNAME=[$10], LOC=[$11]) LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{8}]) LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], ... COMM=[$6], DEPTNO=[$7], $f8=[+(10, $7)]) LogicalTableScan(table=[[scott, EMP]]) LogicalFilter(condition=[=($0, $cor0.$f8)]) LogicalTableScan(table=[[scott, DEPT]])
Essentially this transformation moves the computation over a correlated expression from the inner loop to the outer loop. It materializes the computation on the left side and flattens expressions on correlated variables on the right side.
-
Field Summary
Fields inherited from class org.apache.calcite.rel.RelShuttleImpl
stack
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.calcite.rel.RelHomogeneousShuttle
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
Methods inherited from class org.apache.calcite.rel.RelShuttleImpl
visit, visit, visit, visitChild, visitChildren
-
Constructor Details
-
CorrelateProjectExtractor
-
-
Method Details
-
visit
- Specified by:
visit
in interfaceRelShuttle
- Overrides:
visit
in classRelHomogeneousShuttle
-