xiedeyantu commented on code in PR #4322:
URL: https://github.com/apache/calcite/pull/4322#discussion_r2056013647
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -10407,4 +10407,38 @@ private void
checkLoptOptimizeJoinRule(LoptOptimizeJoinRule rule) {
.withRule(CoreRules.JOIN_CONDITION_PUSH)
.check();
}
+
+ /** Test case of
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6973">[CALCITE-6973]
+ * Add rule for convert Minus to Filter</a>. */
+ @Test void testMinusToFilterRule() {
+ final String sql = "SELECT mgr, comm FROM emp WHERE mgr = 12\n"
+ + "EXCEPT\n"
+ + "SELECT mgr, comm FROM emp WHERE comm = 5\n";
+ sql(sql)
+ .withPreRule(CoreRules.PROJECT_FILTER_TRANSPOSE)
+ .withRule(CoreRules.MINUS_TO_FILTER)
+ .check();
+ }
+
+ /** Test case of
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6973">[CALCITE-6973]
+ * Add rule for convert Minus to Filter</a>. */
+ @Test void testMinusToFilterRule2() {
+ final Function<RelBuilder, RelNode> relFn = b -> b
+ .scan("EMP")
+ .project(b.field("MGR"), b.field("COMM"))
+ .filter(b.lessThan(b.field("MGR"), b.literal(20)))
Review Comment:
Thank @NobiGo and @asolimando for your response. The reason I wrote it this
way is that the `left input` can be a `filter` or not, or even multiple nested
`filter`s. Since the input of `MINUS` needs to be traversed regardless, I took
the opportunity to implement this simple capability. If everyone thinks it's
redundant, I can make the rule more pure.
--
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]