From 2376a3a743d2ece3f81aee881b2fc381803def47 Mon Sep 17 00:00:00 2001 From: NobiGo Date: Wed, 16 Feb 2022 14:41:03 +0800 Subject: [PATCH] [CALCITE-4912] Confusing javadoc of RexSimplify.simplify --- .../src/main/java/org/apache/calcite/rex/RexSimplify.java | 4 ++-- .../test/java/org/apache/calcite/rex/RexProgramTest.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java index 7c0aa6bb3138..8dd53a985888 100644 --- a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java +++ b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java @@ -204,8 +204,8 @@ public RexNode simplifyPreservingType(RexNode e, RexUnknownAs unknownAs, * *

In particular:

* diff --git a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java index 691c9541e5fd..7f68dec914ca 100644 --- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java +++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java @@ -1003,6 +1003,10 @@ private void checkExponentialCnf(int n) { "false", "IS NULL(?0.i)"); checkSimplifyUnchanged(gt(iRef, hRef)); + // "x = 1 or not x = 1 or x is null" simplifies to "true" + checkSimplify(or(eq(hRef, literal(1)), not(eq(hRef, literal(1))), isNull(hRef)), "true"); + checkSimplify(or(eq(iRef, literal(1)), not(eq(iRef, literal(1))), isNull(iRef)), "true"); + // "(not x) is null" to "x is null" checkSimplify(isNull(not(vBool())), "IS NULL(?0.bool0)"); checkSimplify(isNull(not(vBoolNotNull())), "false"); @@ -1130,7 +1134,7 @@ private void checkExponentialCnf(int n) { // condition with null value for range checkSimplifyFilter(and(gt(aRef, nullBool), ge(bRef, literal(1))), "false"); - // condition "1 < a && 5 < x" yields "5 < x" + // condition "1 < a && 5 < a" yields "5 < a" checkSimplifyFilter( and(lt(literal(1), aRef), lt(literal(5), aRef)), RelOptPredicateList.EMPTY, @@ -1142,7 +1146,7 @@ private void checkExponentialCnf(int n) { RelOptPredicateList.EMPTY, "SEARCH(?0.a, Sarg[(1..5)])"); - // condition "1 > a && 5 > x" yields "1 > a" + // condition "1 > a && 5 > a" yields "1 > a" checkSimplifyFilter( and(gt(literal(1), aRef), gt(literal(5), aRef)), RelOptPredicateList.EMPTY,