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


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -2339,14 +2353,28 @@ private void verify(RexNode before, RexNode simplified, 
RexUnknownAs unknownAs)
           continue assignment_loop;
         }
       }
-      Comparable v0 = RexInterpreter.evaluate(foo0.e, map);
-      if (v0 == null) {
-        throw new AssertionError("interpreter returned null for " + foo0.e);
-      }
-      Comparable v1 = RexInterpreter.evaluate(foo1.e, map);
-      if (v1 == null) {
-        throw new AssertionError("interpreter returned null for " + foo1.e);
+      Pair<Comparable, RuntimeException> p0 = evaluate(foo0.e, map);
+      Pair<Comparable, RuntimeException> p1 = evaluate(foo1.e, map);
+      if (p0.right != null || p1.right != null) {
+        if (p0.right == null || p1.right == null) {
+          throw Util.first(p0.right, p1.right);
+        }
+        if (!p0.right.getClass().equals(p1.right.getClass())) {
+          AssertionError error = new AssertionError("exception class does not 
match");
+          error.addSuppressed(p0.right);
+          error.addSuppressed(p1.right);
+          throw error;
+        }
+        if (!java.util.Objects.equals(p0.right.getMessage(), 
p1.right.getMessage())) {
+          AssertionError error = new AssertionError("exception message does 
not match");
+          error.addSuppressed(p0.right);
+          error.addSuppressed(p1.right);
+          throw error;
+        }
+        continue;
       }

Review Comment:
   No, the exception or throwable classes don't provide an implementation of 
equals, at least not the ones that I looked at. They fall-back to Object's 
`equals` method, which is just a `return (this == obj);`. The two exceptions to 
be compared are created at different times, so they cannot be the same 
instance. So we need to provide our own way to compare them.



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