danny0405 commented on a change in pull request #2144:
URL: https://github.com/apache/calcite/pull/2144#discussion_r485404856



##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -1640,6 +1640,21 @@ private void checkExponentialCnf(int n) {
         .expandedSearch(expanded);
   }
 
+  @Test void testSimplifyRange6() {
+    // An IS NULL condition would not usually become a Sarg,
+    // but here it is combined with another condition, and together they cross
+    // the complexity threshold.
+    final RexNode aRef = input(tInt(true), 0);
+    final RexNode bRef = input(tInt(true), 1);
+    // a in (1, 2) or b is null
+    RexNode expr = or(eq(aRef, literal(1)), eq(aRef, literal(2)), 
isNull(bRef));
+    final String simplified =
+        "OR(SEARCH($1, Sarg[, null]), SEARCH($0, Sarg[1, 2]))";
+    final String expanded = "OR(IS NULL($1), OR(=($0, 1), =($0, 2)))";
+    checkSimplify(expr, simplified)

Review comment:
       Can `Sarg[, null]` be promoted to `Sarg[null]` ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to