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


##########
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:
   I changed my mind, I don't think this is right.
   If you remove the cast the type of the entire expression changes.
   For example `CASE 0 WHEN 1 THEN (CAST 1 AS BIGINT) / 0 ELSE 2`
   Here the result should be 2 with type BIGINT, but with your simplification 
the result will have type INT because the cast to BIGINT is removed.



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