You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by as...@apache.org on 2021/12/19 09:14:26 UTC

[calcite] branch master updated: [CALCITE-4917] Add test for 'a IS NOT NULL AND a = b' simplification

This is an automated email from the ASF dual-hosted git repository.

asolimando 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 7a7b37f  [CALCITE-4917] Add test for 'a IS NOT NULL AND a = b' simplification
7a7b37f is described below

commit 7a7b37fc1f4bd2121643539b0fd8e9c4f0f8ed09
Author: Alessandro Solimando <al...@gmail.com>
AuthorDate: Thu Dec 2 15:13:21 2021 +0100

    [CALCITE-4917] Add test for 'a IS NOT NULL AND a = b' simplification
---
 .../src/test/java/org/apache/calcite/rex/RexProgramTest.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 8b9c52f..9edb64a 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
@@ -1710,6 +1710,18 @@ class RexProgramTest extends RexProgramTestBase {
         .expandedSearch(expanded);
   }
 
+  @Test void testSimplifyAndIsNotNullWithEquality() {
+    // "AND(IS NOT NULL(x), =(x, y)) => AND(IS NOT NULL(x), =(x, y)) (unknownAsFalse=false),
+    // "=(x, y)" (unknownAsFalse=true)
+    checkSimplify2(and(isNotNull(vInt(0)), eq(vInt(0), vInt(1))),
+        "AND(IS NOT NULL(?0.int0), =(?0.int0, ?0.int1))",
+        "=(?0.int0, ?0.int1)");
+
+    // "AND(IS NOT NULL(x), =(x, y)) => "=(x, y)"
+    checkSimplify(and(isNotNull(vIntNotNull(0)), eq(vIntNotNull(0), vInt(1))),
+        "=(?0.notNullInt0, ?0.int1)");
+  }
+
   @Test void testSimplifyAndIsNull() {
     final RexNode aRef = input(tInt(true), 0);
     final RexNode bRef = input(tInt(true), 1);