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


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1153,16 +1153,15 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs 
unknownAs) {
       return rexBuilder.makeLiteral(true);
     }
     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);
+      // to keep this simplification, we must return IS NOT NULL(a),
+      // even if we cannot do anything else
     }
     if (predicates.pulledUpPredicates.contains(a)) {
       return rexBuilder.makeLiteral(true);
     }
     if (hasCustomNullabilityRules(a.getKind())) {
-      return null;
+      return rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, a);

Review Comment:
   Let's carry the source position as much as possible, there is no cost for 
it, and it may be used by other rewrites in calls that may throw.



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