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

rubenql 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 ea2b32e  [CALCITE-4258] SqlToRelConverter: SELECT 1 IS [NOT] DISTINCT 
FROM NULL fails with AssertionError
ea2b32e is described below

commit ea2b32e11dc6a0744fc93b8d33d7dfa1da70e674
Author: rubenada <[email protected]>
AuthorDate: Wed Sep 16 13:29:13 2020 +0100

    [CALCITE-4258] SqlToRelConverter: SELECT 1 IS [NOT] DISTINCT FROM NULL 
fails with AssertionError
---
 .../apache/calcite/plan/RelOptPredicateList.java   |  5 +++--
 core/src/test/resources/sql/misc.iq                | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java
index b38b135..8d06739 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java
@@ -217,10 +217,11 @@ public class RelOptPredicateList {
       }
     }
     if (SqlKind.COMPARISON.contains(e.getKind())) {
-      // A comparison with a literal, such as 'ref < 10', is not null if 'ref'
+      // A comparison with a (non-null) literal, such as 'ref < 10', is not 
null if 'ref'
       // is not null.
       RexCall call = (RexCall) e;
-      if (call.getOperands().get(1) instanceof RexLiteral) {
+      if (call.getOperands().get(1) instanceof RexLiteral
+          && !((RexLiteral) call.getOperands().get(1)).isNull()) {
         return isEffectivelyNotNull(call.getOperands().get(0));
       }
     }
diff --git a/core/src/test/resources/sql/misc.iq 
b/core/src/test/resources/sql/misc.iq
index 625e211..e73a17e 100644
--- a/core/src/test/resources/sql/misc.iq
+++ b/core/src/test/resources/sql/misc.iq
@@ -64,6 +64,28 @@ group by "hr"."emps"."empid";
 
 !ok
 
+# [CALCITE-4258] SqlToRelConverter: SELECT 1 IS [NOT] DISTINCT FROM NULL fails 
with AssertionError
+SELECT 1 IS DISTINCT FROM NULL;
++--------+
+| EXPR$0 |
++--------+
+| true   |
++--------+
+(1 row)
+
+!ok
+
+# [CALCITE-4258] SqlToRelConverter: SELECT 1 IS [NOT] DISTINCT FROM NULL fails 
with AssertionError
+SELECT 1 IS NOT DISTINCT FROM NULL;
++--------+
+| EXPR$0 |
++--------+
+| false  |
++--------+
+(1 row)
+
+!ok
+
 # Case-sensitive errors
 select empid from "hr"."emps";
 Column 'EMPID' not found in any table; did you mean 'empid'?

Reply via email to