asolimando commented on code in PR #4322:
URL: https://github.com/apache/calcite/pull/4322#discussion_r2055937455
##########
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:
I strongly agree, individual rules should be kept as simple as possible and
should rely on other rules whenever it makes sense like in this case
--
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]