@@ -440,7 +440,7 @@ private RexNode simplifyArithmetic(RexCall e) {
440440 assert e .getOperands ().size () == 2 ;
441441
442442 switch (e .getKind ()) {
443- // These simplifications are safe for both checked and unchecked arithemtic .
443+ // These simplifications are safe for both checked and unchecked arithmetic .
444444 case PLUS :
445445 case CHECKED_PLUS :
446446 return simplifyPlus (e );
@@ -454,7 +454,7 @@ private RexNode simplifyArithmetic(RexCall e) {
454454 case CHECKED_DIVIDE :
455455 return simplifyDivide (e );
456456 default :
457- throw new IllegalArgumentException ("Unsupported arithmeitc operation " + e .getKind ());
457+ throw new IllegalArgumentException ("Unsupported arithmetic operation " + e .getKind ());
458458 }
459459 }
460460
@@ -2309,6 +2309,20 @@ private RexNode simplifyOrs(List<RexNode> terms, RexUnknownAs unknownAs) {
23092309 return RexUtil .composeDisjunction (rexBuilder , terms );
23102310 }
23112311
2312+ private Pair <Comparable , RuntimeException > evaluate (RexNode e , Map <RexNode , Comparable > map ) {
2313+ Comparable c = null ;
2314+ RuntimeException ex = null ;
2315+ try {
2316+ c = RexInterpreter .evaluate (e , map );
2317+ } catch (RuntimeException exception ) {
2318+ ex = exception ;
2319+ }
2320+ if (c == null && ex == null ) {
2321+ throw new AssertionError ("interpreter returned null for " + e );
2322+ }
2323+ return Pair .of (c , ex );
2324+ }
2325+
23122326 private void verify (RexNode before , RexNode simplified , RexUnknownAs unknownAs ) {
23132327 if (simplified .isAlwaysFalse ()
23142328 && before .isAlwaysTrue ()) {
@@ -2339,14 +2353,28 @@ private void verify(RexNode before, RexNode simplified, RexUnknownAs unknownAs)
23392353 continue assignment_loop ;
23402354 }
23412355 }
2342- Comparable v0 = RexInterpreter .evaluate (foo0 .e , map );
2343- if (v0 == null ) {
2344- throw new AssertionError ("interpreter returned null for " + foo0 .e );
2345- }
2346- Comparable v1 = RexInterpreter .evaluate (foo1 .e , map );
2347- if (v1 == null ) {
2348- throw new AssertionError ("interpreter returned null for " + foo1 .e );
2356+ Pair <Comparable , RuntimeException > p0 = evaluate (foo0 .e , map );
2357+ Pair <Comparable , RuntimeException > p1 = evaluate (foo1 .e , map );
2358+ if (p0 .right != null || p1 .right != null ) {
2359+ if (p0 .right == null || p1 .right == null ) {
2360+ throw Util .first (p0 .right , p1 .right );
2361+ }
2362+ if (!p0 .right .getClass ().equals (p1 .right .getClass ())) {
2363+ AssertionError error = new AssertionError ("exception class does not match" );
2364+ error .addSuppressed (p0 .right );
2365+ error .addSuppressed (p1 .right );
2366+ throw error ;
2367+ }
2368+ if (!java .util .Objects .equals (p0 .right .getMessage (), p1 .right .getMessage ())) {
2369+ AssertionError error = new AssertionError ("exception message does not match" );
2370+ error .addSuppressed (p0 .right );
2371+ error .addSuppressed (p1 .right );
2372+ throw error ;
2373+ }
2374+ continue ;
23492375 }
2376+ Comparable v0 = p0 .left ;
2377+ Comparable v1 = p1 .left ;
23502378 if (before .getType ().getSqlTypeName () == SqlTypeName .BOOLEAN ) {
23512379 switch (unknownAs ) {
23522380 case FALSE :
0 commit comments