Source:
private void verify(RexNode before, RexNode simplified, RexUnknownAs unknownAs) { if (simplified.isAlwaysFalse() && before.isAlwaysTrue()) { throw new AssertionError("always true [" + before + "] simplified to always false [" + simplified + "]"); } if (simplified.isAlwaysTrue() && before.isAlwaysFalse()) { throw new AssertionError("always false [" + before + "] simplified to always true [" + simplified + "]"); } final RexAnalyzer foo0 = new RexAnalyzer(before, predicates); final RexAnalyzer foo1 = new RexAnalyzer(simplified, predicates); if (foo0.unsupportedCount > 0 || foo1.unsupportedCount > 0) { return; } if (!foo0.variables.containsAll(foo1.variables)) { throw new AssertionError("variable mismatch: " + before + " has " + foo0.variables + ", " + simplified + " has " + foo1.variables); } assignment_loop: for (Map<RexNode, Comparable> map : foo0.assignments()) { for (RexNode predicate : predicates.pulledUpPredicates) { final Comparable v = RexInterpreter.evaluate(predicate, map); if (!v.equals(true)) { 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); } if (before.getType().getSqlTypeName() == SqlTypeName.BOOLEAN) { switch (unknownAs) { case FALSE: case TRUE: if (v0 == NullSentinel.INSTANCE) { v0 = unknownAs.toBoolean(); } if (v1 == NullSentinel.INSTANCE) { v1 = unknownAs.toBoolean(); } } } if (!v0.equals(v1)) { throw new AssertionError("result mismatch: when applied to " + map + ", " + before + " yielded " + v0 + ", and " + simplified + " yielded " + v1); } } return; }

Target:
private void verify(RexNode before, RexNode simplified, RexUnknownAs unknownAs) { if (simplified.isAlwaysFalse() && before.isAlwaysTrue()) { throw new AssertionError("always true [" + before + "] simplified to always false [" + simplified + "]"); } if (simplified.isAlwaysTrue() && before.isAlwaysFalse()) { throw new AssertionError("always false [" + before + "] simplified to always true [" + simplified + "]"); } final RexAnalyzer foo0 = new RexAnalyzer(before, predicates); final RexAnalyzer foo1 = new RexAnalyzer(simplified, predicates); if (foo0.unsupportedCount > 0 || foo1.unsupportedCount > 0) { return; } if (!foo0.variables.containsAll(foo1.variables)) { throw new AssertionError("variable mismatch: " + before + " has " + foo0.variables + ", " + simplified + " has " + foo1.variables); } assignment_loop: for (Map<RexNode, Comparable> map : foo0.assignments()) { for (RexNode predicate : predicates.pulledUpPredicates) { final Comparable v = RexInterpreter.evaluate(predicate, map); if (!v.equals(true)) { 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); } if (before.getType().getSqlTypeName() == SqlTypeName.BOOLEAN) { switch (unknownAs) { case FALSE: case TRUE: if (v0 == NullSentinel.INSTANCE) { v0 = unknownAs.toBoolean(); } if (v1 == NullSentinel.INSTANCE) { v1 = unknownAs.toBoolean(); } } } if (!v0.equals(v1)) { throw new AssertionError("result mismatch: when applied to " + map + ", " + before + " yielded " + v0 + ", and " + simplified + " yielded " + v1); } } }