NobiGo commented on code in PR #3975: URL: https://github.com/apache/calcite/pull/3975#discussion_r1776179079
########## core/src/test/java/org/apache/calcite/test/RelMetadataTest.java: ########## @@ -2593,6 +2593,31 @@ private void checkPredicates(RelOptCluster cluster, RelOptTable empTable, } + /** Test case for + * <a href="https://issues.apache.org/jira/browse/CALCITE-6592">[CALCITE-6592] + * RelMdPredicates pull up wrong predicate from UNION when it's input include NULL VALUE</a>. */ + @Test void testPullUpPredicatesFromUnionWithValues1() { + final String sql = "select cast(null as integer) as a\n" + + "union all\n" + + "select 5 as a"; + final Union rel = (Union) sql(sql).toRel(); + final RelMetadataQuery mq = rel.getCluster().getMetadataQuery(); + RelOptPredicateList inputSet = mq.getPulledUpPredicates(rel); + ImmutableList<RexNode> pulledUpPredicates = inputSet.pulledUpPredicates; + assertThat(pulledUpPredicates, sortsAs("[OR(null, =($0, 5))]")); Review Comment: @zabetak Hi, testPullUpPredicatesFromUnionWithValues3 added for more columns. Maybe we should extract nothing when we can't get a specific value like OR(IS NULL($0), =($0, 5)). WDYT? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
