You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by xi...@apache.org on 2022/02/18 01:55:58 UTC
[calcite] branch master updated: [CALCITE-4912] Confusing javadoc of RexSimplify.simplify
This is an automated email from the ASF dual-hosted git repository.
xiong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 595da9b [CALCITE-4912] Confusing javadoc of RexSimplify.simplify
595da9b is described below
commit 595da9b8b2d9f76b5bc46fbf8fb4d82efa47e9ee
Author: NobiGo <no...@gmail.com>
AuthorDate: Wed Feb 16 14:41:03 2022 +0800
[CALCITE-4912] Confusing javadoc of RexSimplify.simplify
---
core/src/main/java/org/apache/calcite/rex/RexSimplify.java | 4 ++--
core/src/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 7c0aa6b..8dd53a9 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 class RexSimplify {
*
* <p>In particular:</p>
* <ul>
- * <li>{@code simplify(x = 1 AND y = 2 AND NOT x = 1)}
- * returns {@code y = 2}</li>
+ * <li>{@code simplify(x = 1 OR NOT x = 1 OR x IS NULL)}
+ * returns {@code TRUE}</li>
* <li>{@code simplify(x = 1 AND FALSE)}
* returns {@code FALSE}</li>
* </ul>
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 691c954..7f68dec 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 @@ class RexProgramTest extends RexProgramTestBase {
"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 @@ class RexProgramTest extends RexProgramTestBase {
// 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 @@ class RexProgramTest extends RexProgramTestBase {
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,