rubenada commented on code in PR #5184:
URL: https://github.com/apache/calcite/pull/5184#discussion_r3802663214


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1258,15 +1286,32 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs 
unknownAs) {
     if (hasCustomNullabilityRules(a.getKind())) {
       return simplifiedResult;
     }
-    if (!isSafe) {
-      return simplifiedResult;
-    }
     switch (Strong.policy(a)) {
     case NOT_NULL:
+      // Drops the subtree; require full-tree safety so we don't hide runtime
+      // errors inside
+      if (!isSafe) {
+        return simplifiedResult;
+      }
       return rexBuilder.makeLiteral(false);
     case ANY:
       // "f" is a strong operator, so "f(operand0, operand1) IS NULL" 
simplifies
-      // to "operand0 IS NULL OR operand1 IS NULL"
+      // to "operand0 IS NULL OR operand1 IS NULL". This branch PRESERVES the

Review Comment:
   comment simplified



##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -3024,6 +3024,82 @@ trueLiteral, literal(1),
     checkSimplifyUnchanged(div(cast(vVarchar(), tInt(false)), nullInt));
   }
 
+  /** Test cases for peeling {@code IS [NOT] NULL} across a strong outer

Review Comment:
   Done



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

Reply via email to