thomasrebele commented on code in PR #4646:
URL: https://github.com/apache/calcite/pull/4646#discussion_r2563775537


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1152,20 +1152,21 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs 
unknownAs) {
     if (!a.getType().isNullable() && isSafe) {
       return rexBuilder.makeLiteral(true);
     }
+    RexNode simplifiedResult = null;
     if (RexUtil.isLosslessCast(a)) {
-      if (!a.getType().isNullable()) {
-        return rexBuilder.makeLiteral(true);
-      }
-      return rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, 
RexUtil.removeCast(a));
+      a = RexUtil.removeCast(a);

Review Comment:
   The lossless CAST simplification only applies to a cast directly below an 
`IS NOT NULL` (or `IS NULL` respectively). In that case, the cast would map 
`NULL` to `NULL` and non-NULL values to non-NULL values, so it does not change 
the result of the `IS NOT NULL`. The [implementation on the main 
branch](https://github.com/apache/calcite/blob/abd7ca25943513716d1ba2b592107e2e3f01cb46/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1156-L1161)
 removes the cast as well. Your counterexample does not apply here, as it is 
not of the form `IS NOT NULL(CAST(...))`.



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