Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-4936] Generalize FilterCalcMergeRule and ProjectCalcMergeRule #2646

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,13 +28,13 @@

/**
* Planner rule that merges a
* {@link org.apache.calcite.rel.logical.LogicalCalc} onto a
* {@link org.apache.calcite.rel.logical.LogicalCalc}.
* {@link org.apache.calcite.rel.core.Calc} onto a
* {@link org.apache.calcite.rel.core.Calc}.
*
* <p>The resulting {@link org.apache.calcite.rel.logical.LogicalCalc} has the
* <p>The resulting {@link org.apache.calcite.rel.core.Calc} has the
* same project list as the upper
* {@link org.apache.calcite.rel.logical.LogicalCalc}, but expressed in terms of
* the lower {@link org.apache.calcite.rel.logical.LogicalCalc}'s inputs.
* {@link org.apache.calcite.rel.core.Calc}, but expressed in terms of
* the lower {@link org.apache.calcite.rel.core.Calc}'s inputs.
*
* @see CoreRules#CALC_MERGE
*/
Expand Down
Expand Up @@ -21,7 +21,6 @@
import org.apache.calcite.rel.core.Calc;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.logical.LogicalCalc;
import org.apache.calcite.rel.logical.LogicalFilter;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexProgram;
import org.apache.calcite.rex.RexProgramBuilder;
Expand All @@ -31,9 +30,9 @@

/**
* Planner rule that merges a
* {@link org.apache.calcite.rel.logical.LogicalFilter} and a
* {@link org.apache.calcite.rel.logical.LogicalCalc}. The
* result is a {@link org.apache.calcite.rel.logical.LogicalCalc}
* {@link org.apache.calcite.rel.core.Filter} and a
* {@link org.apache.calcite.rel.core.Calc}. The
* result is a {@link org.apache.calcite.rel.core.Calc}
* whose filter condition is the logical AND of the two.
*
* @see FilterMergeRule
Expand All @@ -60,8 +59,8 @@ public FilterCalcMergeRule(RelBuilderFactory relBuilderFactory) {
//~ Methods ----------------------------------------------------------------

@Override public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = call.rel(0);
final LogicalCalc calc = call.rel(1);
final Filter filter = call.rel(0);
final Calc calc = call.rel(1);

// Don't merge a filter onto a calc which contains windowed aggregates.
// That would effectively be pushing a multiset down through a filter.
Expand All @@ -87,8 +86,8 @@ public FilterCalcMergeRule(RelBuilderFactory relBuilderFactory) {
topProgram,
bottomProgram,
rexBuilder);
final LogicalCalc newCalc =
LogicalCalc.create(calc.getInput(), mergedProgram);
final Calc newCalc =
calc.copy(calc.getTraitSet(), calc.getInput(), mergedProgram);
call.transformTo(newCalc);
}

Expand Down
Expand Up @@ -35,13 +35,13 @@

/**
* Planner rule that merges a
* {@link org.apache.calcite.rel.logical.LogicalProject} and a
* {@link org.apache.calcite.rel.logical.LogicalCalc}.
* {@link org.apache.calcite.rel.core.Project} and a
* {@link org.apache.calcite.rel.core.Calc}.
*
* <p>The resulting {@link org.apache.calcite.rel.logical.LogicalCalc} has the
* <p>The resulting {@link org.apache.calcite.rel.core.Calc} has the
* same project list as the original
* {@link org.apache.calcite.rel.logical.LogicalProject}, but expressed in terms
* of the original {@link org.apache.calcite.rel.logical.LogicalCalc}'s inputs.
* {@link org.apache.calcite.rel.core.Project}, but expressed in terms
* of the original {@link org.apache.calcite.rel.core.Calc}'s inputs.
*
* @see FilterCalcMergeRule
* @see CoreRules#PROJECT_CALC_MERGE
Expand Down Expand Up @@ -82,8 +82,6 @@ public ProjectCalcMergeRule(RelBuilderFactory relBuilderFactory) {
project.getRowType(),
cluster.getRexBuilder());
if (RexOver.containsOver(program)) {
LogicalCalc projectAsCalc = LogicalCalc.create(calc, program);
zabetak marked this conversation as resolved.
Show resolved Hide resolved
call.transformTo(projectAsCalc);
return;
}

Expand All @@ -105,8 +103,8 @@ public ProjectCalcMergeRule(RelBuilderFactory relBuilderFactory) {
topProgram,
bottomProgram,
rexBuilder);
final LogicalCalc newCalc =
LogicalCalc.create(calc.getInput(), mergedProgram);
final Calc newCalc =
calc.copy(calc.getTraitSet(), calc.getInput(), mergedProgram);
call.transformTo(newCalc);
}

Expand Down