This is an automated email from the ASF dual-hosted git repository.

zhenchen 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 3c85e06d90 [CALCITE-4525] Pull up predicate will lose some predicates 
when project contains same RexInputRef
3c85e06d90 is described below

commit 3c85e06d908d4b0c3027d6830cbee308fe638093
Author: Zhen Chen <[email protected]>
AuthorDate: Sun Dec 7 17:33:25 2025 +0800

    [CALCITE-4525] Pull up predicate will lose some predicates when project 
contains same RexInputRef
---
 .../test/java/org/apache/calcite/test/RelMetadataTest.java  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java 
b/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
index 9213bc2345..e8cc0eb81a 100644
--- a/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
@@ -3764,6 +3764,19 @@ private void checkPredicates(RelOptCluster cluster, 
RelOptTable empTable,
     assertThat(pulledUpPredicates, sortsAs("[]"));
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-4525";>[CALCITE-4525]
+   * Pull up predicate will lose some predicates when project contains same 
RexInputRef</a>. */
+  @Test public void testPullUpPredicatesFromProject6() {
+    final String sql = "select MGR, MGR as manager, MGR as manager1"
+        + " from (select * from emp where MGR = 0)";
+    final RelNode rel = sql(sql).toRel();
+    final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
+    RelOptPredicateList inputSet = mq.getPulledUpPredicates(rel);
+    ImmutableList<RexNode> pulledUpPredicates = inputSet.pulledUpPredicates;
+    assertThat(pulledUpPredicates, sortsAs("[=($0, 0), =($1, 0), =($2, 0)]"));
+  }
+
   /** Test case for
    * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6599";>[CALCITE-6599]
    * RelMdPredicates should pull up more predicates from VALUES

Reply via email to