mihaibudiu commented on code in PR #4646:
URL: https://github.com/apache/calcite/pull/4646#discussion_r2557883653
##########
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:
what is the difference between returning null and creating a new call?
If a is unchanged, perhaps you should return null - less wasteful
Also, please use the makeCall version which preserves the source position.
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1212,16 +1211,15 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs
unknownAs) {
return rexBuilder.makeLiteral(false);
}
if (RexUtil.isLosslessCast(a)) {
- if (!a.getType().isNullable()) {
- return rexBuilder.makeLiteral(false);
- }
- return rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
RexUtil.removeCast(a));
+ a = RexUtil.removeCast(a);
+ // to keep this simplification, we must return IS NULL(a),
Review Comment:
what does it mean "keep this simplification?"
--
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]