This is an automated email from the ASF dual-hosted git repository.
xiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new d9363a952c Revert [CALCITE-5036]
`RelMetadataQuery#getPulledUpPredicates` support to analyze constant key for
the operator of IS_NOT_DISTINCT_FROM
d9363a952c is described below
commit d9363a952ce2e1905cca62cdee66076424267503
Author: Xiong Duan <[email protected]>
AuthorDate: Fri Dec 20 20:28:16 2024 +0800
Revert [CALCITE-5036] `RelMetadataQuery#getPulledUpPredicates` support to
analyze constant key for the operator of IS_NOT_DISTINCT_FROM
---
.../java/org/apache/calcite/rel/metadata/RelMdPredicates.java | 9 +--------
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java | 2 ++
.../test/resources/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 396b3300b4..f162f27e83 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 class RelMdPredicates
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 680c8298a1..b0324902f1 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 @@ class RelOptRulesTest extends RelOptTestBase {
+ "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 @@ class RelOptRulesTest extends RelOptTestBase {
+ "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 fba6338e05..25520355ae 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=[$
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$9], ENAME0=[$10],
JOB0=[$11], MGR0=[$12], HIREDATE0=[$13], SAL0=[$14], COMM0=[$15],
DEPTNO0=[$16], SLACKER0=[$17])
LogicalJoin(condition=[=($16, $7)], joinType=[inner])
- LogicalFilter(condition=[NOT(OR(=($7, 4), =($7, 6)))])
- LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalFilter(condition=[SEARCH($7, Sarg[(-∞..4), (4..6), (6..+∞)])])
+ LogicalFilter(condition=[NOT(OR(=($7, 4), =($7, 6)))])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[SEARCH($7, Sarg[(-∞..4), (4..6), (6..+∞)])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
@@ -8920,7 +8921,7 @@ LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)],
EXPR$2=[+($0, $7)])
<Resource name="planAfter">
<![CDATA[
LogicalProject(DEPTNO=[10], EXPR$1=[11], EXPR$2=[+($0, 10)])
- LogicalFilter(condition=[OR(AND(IS NULL($7), IS NULL(10)), IS TRUE(=($7,
10)))])
+ LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
@@ -8957,7 +8958,7 @@ LogicalProject(MGR=[$3], DEPTNO=[$7])
<Resource name="planAfter">
<![CDATA[
LogicalProject(MGR=[null:INTEGER], DEPTNO=[$7])
- LogicalFilter(condition=[OR(AND(IS NULL($3), IS NULL(null:INTEGER)), IS
TRUE(=($3, null)))])
+ LogicalFilter(condition=[IS NULL($3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>