From e681096edcc76da5567139561eb9900671692874 Mon Sep 17 00:00:00 2001 From: nobigo Date: Fri, 20 Dec 2024 20:28:16 +0800 Subject: [PATCH] Revert [CALCITE-5036] `RelMetadataQuery#getPulledUpPredicates` support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM --- .../org/apache/calcite/rel/metadata/RelMdPredicates.java | 9 +-------- .../java/org/apache/calcite/test/RelOptRulesTest.java | 2 ++ .../org/apache/calcite/test/RelOptRulesTest.xml | 9 +++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java index 396b3300b4a..f162f27e832 100644 --- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java +++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java @@ -308,18 +308,11 @@ public RelOptPredicateList getPredicates(Filter filter, RelMetadataQuery mq) { final RexBuilder rexBuilder = filter.getCluster().getRexBuilder(); final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input); - // Simplify condition using RexSimplify. - final RexNode condition = filter.getCondition(); - final RexExecutor executor = - Util.first(filter.getCluster().getPlanner().getExecutor(), RexUtil.EXECUTOR); - final RexSimplify simplify = new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, executor); - final RexNode simplifiedCondition = simplify.simplify(condition); - return Util.first(inputInfo, RelOptPredicateList.EMPTY) .union(rexBuilder, RelOptPredicateList.of(rexBuilder, RexUtil.retainDeterministic( - RelOptUtil.conjunctions(simplifiedCondition)))); + RelOptUtil.conjunctions(filter.getCondition())))); } /** diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java index 680c8298a13..b0324902f1d 100644 --- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java +++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java @@ -5854,6 +5854,7 @@ private HepProgram getTransitiveProgram() { + "where deptno is not distinct from 10"; sql(sql).withPre(getTransitiveProgram()) .withRule(CoreRules.JOIN_PUSH_TRANSITIVE_PREDICATES, + CoreRules.FILTER_REDUCE_EXPRESSIONS, CoreRules.PROJECT_REDUCE_EXPRESSIONS) .check(); } @@ -5864,6 +5865,7 @@ private HepProgram getTransitiveProgram() { + "where mgr is not distinct from null"; sql(sql).withPre(getTransitiveProgram()) .withRule(CoreRules.JOIN_PUSH_TRANSITIVE_PREDICATES, + CoreRules.FILTER_REDUCE_EXPRESSIONS, CoreRules.PROJECT_REDUCE_EXPRESSIONS) .check(); } diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml index fba6338e05f..25520355ae7 100644 --- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml +++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml @@ -5165,8 +5165,9 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$ @@ -8920,7 +8921,7 @@ LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)]) @@ -8957,7 +8958,7 @@ LogicalProject(MGR=[$3], DEPTNO=[$7])