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


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -1028,9 +1037,25 @@ private RexNode simplifyIs(RexCall call, RexUnknownAs 
unknownAs) {
       switch (a.getKind()) {
       case LITERAL:
         return rexBuilder.makeLiteral(!((RexLiteral) a).isNull());
+      case 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(false);
+        }
+        if (!op1.isA(SqlKind.LITERAL)) {
+          return rexBuilder.makeCall(
+              SqlStdOperatorTable.IS_NOT_NULL, simplifyGenericNode((RexCall) 
a));
+        }
+        if (checkLiteralValue(op1, BigDecimal.ZERO)) {
+          return rexBuilder.makeCall(
+              SqlStdOperatorTable.IS_NOT_NULL, simplifyGenericNode((RexCall) 
a));
+        }
+        // op1 is a non-null and non-zero literal, so simplify op0
+        return simplifyIsNotNull(op0);
+      }
       default:
-        throw new AssertionError("every CUSTOM policy needs a handler, "
-            + a.getKind());
+        return null;

Review Comment:
   @zabetak specifically asked for this in his 
[review](https://github.com/apache/calcite/pull/4505#discussion_r2435623000).



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