Skip to content

Commit

Permalink
[CALCITE-6674] Make RelDecorrelator rules configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenada committed Nov 10, 2024
1 parent aced08d commit edd6d11
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rex.RexExecutor;
import org.apache.calcite.sql2rel.RelDecorrelator;
import org.apache.calcite.util.CancelFlag;
import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;
Expand Down Expand Up @@ -86,6 +87,8 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {

private @Nullable RexExecutor executor;

private @Nullable RelDecorrelator decorrelator;

//~ Constructors -----------------------------------------------------------

/**
Expand Down Expand Up @@ -290,6 +293,17 @@ protected void onNewClass(RelNode node) {
return executor;
}

@Override public void setDecorrelator(@Nullable RelDecorrelator decorrelator) {
this.decorrelator = decorrelator;
}

@Override public RelDecorrelator getDecorrelator() {
if (decorrelator == null) {
throw new IllegalStateException("RelDecorrelator has not been set");
}
return decorrelator;
}

@Override public void onCopy(RelNode rel, RelNode newRel) {
// do nothing
}
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/org/apache/calcite/plan/RelOptPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rex.RexExecutor;
import org.apache.calcite.sql2rel.RelDecorrelator;
import org.apache.calcite.util.CancelFlag;
import org.apache.calcite.util.trace.CalciteTrace;

Expand Down Expand Up @@ -334,6 +335,15 @@ RelNode register(
/** Returns the executor used to evaluate constant expressions. */
@Nullable RexExecutor getExecutor();

/** Sets the decorrelator. */
void setDecorrelator(@Nullable RelDecorrelator decorrelator);

/** Returns the decorrelator used to decorrelate expressions.
*
* @throws IllegalStateException if the decorrelator has not been set
* */
RelDecorrelator getDecorrelator();

/** Called when a relational expression is copied to a similar expression. */
void onCopy(RelNode rel, RelNode newRel);

Expand Down
Loading

0 comments on commit edd6d11

Please sign in to comment.