You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jc...@apache.org on 2020/05/11 14:49:08 UTC
[calcite] branch master updated: [CALCITE-3982] Simplify
FilterMergeRule to rely on RelBuilder instead of RexProgram
This is an automated email from the ASF dual-hosted git repository.
jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new de3bef9 [CALCITE-3982] Simplify FilterMergeRule to rely on RelBuilder instead of RexProgram
de3bef9 is described below
commit de3bef9b06502886f87b60ab36d8e54ebc55f05c
Author: Jesus Camacho Rodriguez <jc...@apache.org>
AuthorDate: Sat May 9 18:27:43 2020 -0700
[CALCITE-3982] Simplify FilterMergeRule to rely on RelBuilder instead of RexProgram
Close apache/calcite#1968
---
.../apache/calcite/rel/rules/FilterMergeRule.java | 38 +---------------------
1 file changed, 1 insertion(+), 37 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/FilterMergeRule.java b/core/src/main/java/org/apache/calcite/rel/rules/FilterMergeRule.java
index a4df314..1517d2c 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/FilterMergeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/FilterMergeRule.java
@@ -22,10 +22,6 @@ import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.SubstitutionRule;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.RelFactories;
-import org.apache.calcite.rex.RexBuilder;
-import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.rex.RexProgram;
-import org.apache.calcite.rex.RexProgramBuilder;
import org.apache.calcite.tools.RelBuilder;
import org.apache.calcite.tools.RelBuilderFactory;
@@ -60,43 +56,11 @@ public class FilterMergeRule extends RelOptRule implements SubstitutionRule {
final Filter topFilter = call.rel(0);
final Filter bottomFilter = call.rel(1);
- // use RexPrograms to merge the two FilterRels into a single program
- // so we can convert the two LogicalFilter conditions to directly
- // reference the bottom LogicalFilter's child
- RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
- RexProgram bottomProgram = createProgram(bottomFilter);
- RexProgram topProgram = createProgram(topFilter);
-
- RexProgram mergedProgram =
- RexProgramBuilder.mergePrograms(
- topProgram,
- bottomProgram,
- rexBuilder);
-
- RexNode newCondition =
- mergedProgram.expandLocalRef(
- mergedProgram.getCondition());
-
final RelBuilder relBuilder = call.builder();
relBuilder.push(bottomFilter.getInput())
- .filter(newCondition);
+ .filter(bottomFilter.getCondition(), topFilter.getCondition());
call.transformTo(relBuilder.build());
}
- /**
- * Creates a RexProgram corresponding to a LogicalFilter
- *
- * @param filterRel the LogicalFilter
- * @return created RexProgram
- */
- private RexProgram createProgram(Filter filterRel) {
- RexProgramBuilder programBuilder =
- new RexProgramBuilder(
- filterRel.getRowType(),
- filterRel.getCluster().getRexBuilder());
- programBuilder.addIdentity();
- programBuilder.addCondition(filterRel.getCondition());
- return programBuilder.getProgram();
- }
}