thomasrebele commented on code in PR #4505:
URL: https://github.com/apache/calcite/pull/4505#discussion_r2486683349
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1189,6 +1102,23 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs
unknownAs) {
}
}
return RexUtil.composeDisjunction(rexBuilder, operands, false);
+ case CUSTOM:
+ if (a.getKind() == SqlKind.DIVIDE) {
+ RexNode op0 = ((RexCall) a).getOperands().get(0);
+ RexNode op1 = ((RexCall) a).getOperands().get(1);
+ if (RexUtil.isNull(op0) || RexUtil.isNull(op1)) {
+ return rexBuilder.makeLiteral(true);
+ }
+ if (!op1.isA(SqlKind.LITERAL)) {
+ return rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
simplifyGenericNode((RexCall) a));
+ }
+ if (checkLiteralValue(op1, BigDecimal.ZERO)) {
+ return rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
simplifyGenericNode((RexCall) a));
+ }
+ // op1 is a non-null and non-zero literal, so simplify op0
+ return simplifyIsNull(op0);
+ }
+ return null;
Review Comment:
It might indeed be possible. I would move this discussion to another ticket,
though: [CALCITE-7263](https://issues.apache.org/jira/browse/CALCITE-7263).
--
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]