calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject calcite git commit: Following [CALCITE-1054], fixing failed tests in CoreQuidemTest
Date Thu, 25 Jan 2018 19:22:06 GMT
Repository: calcite
Updated Branches:
  refs/heads/master d1bada423 -> a59d67725


Following [CALCITE-1054], fixing failed tests in CoreQuidemTest


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/a59d6772
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/a59d6772
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/a59d6772

Branch: refs/heads/master
Commit: a59d677254a10c16920af26d2b19033bbb0e58ce
Parents: d1bada4
Author: maryannxue <maryann.xue@gmail.com>
Authored: Thu Jan 25 11:22:00 2018 -0800
Committer: maryannxue <maryann.xue@gmail.com>
Committed: Thu Jan 25 11:22:00 2018 -0800

----------------------------------------------------------------------
 .../calcite/adapter/enumerable/RexImpTable.java | 27 ++++++++++--------
 core/src/test/resources/sql/misc.iq             | 29 ++++++++++++++++++++
 2 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/a59d6772/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index fe0cc7f..20d340e 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -56,10 +56,8 @@ import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableIntList;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Function;
 import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 import java.lang.reflect.Constructor;
@@ -943,16 +941,23 @@ public class RexImpTable {
       final NullAs nullAs) {
     List<Expression> translatedOperands =
         translator.translateList(call.getOperands());
-    // Make sure the operands have all been handled for nulls before
-    // being passed to the NotNullImplementor.
+    // Make sure the operands marked not null in the translator have all been
+    // handled for nulls before being passed to the NotNullImplementor.
     if (nullAs == NullAs.NOT_POSSIBLE) {
-      translatedOperands = Lists.transform(
-          translatedOperands,
-          new Function<Expression, Expression>() {
-            public Expression apply(Expression e) {
-              return translator.handleNull(e, nullAs);
-            }
-          });
+      List<Expression> nullHandled = translatedOperands;
+      for (int i = 0; i < translatedOperands.size(); i++) {
+        RexNode arg = call.getOperands().get(i);
+        Expression e = translatedOperands.get(i);
+        if (!translator.isNullable(arg)) {
+          if (nullHandled == translatedOperands) {
+            nullHandled = new ArrayList<>(translatedOperands.subList(0, i));
+          }
+          nullHandled.add(translator.handleNull(e, nullAs));
+        } else if (nullHandled != translatedOperands) {
+          nullHandled.add(e);
+        }
+      }
+      translatedOperands = nullHandled;
     }
     Expression result =
         implementor.implement(translator, call, translatedOperands);

http://git-wip-us.apache.org/repos/asf/calcite/blob/a59d6772/core/src/test/resources/sql/misc.iq
----------------------------------------------------------------------
diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq
index e32ffbf..cac239d 100644
--- a/core/src/test/resources/sql/misc.iq
+++ b/core/src/test/resources/sql/misc.iq
@@ -1998,6 +1998,35 @@ select multiset[1,null,2,2-1] as m from (values (1));
 
 !ok
 
+!use catchall
+
+# [CALCITE-1054] NPE caused by wrong code generation for Timestamp fields
+select "sqlTimestamp" as T
+from "everyTypes"
+where "sqlTimestamp" >= {ts '1969-01-01 00:00:00'}
+and "sqlTimestamp" < {ts '1998-01-01 00:00:00'};
++---------------------+
+| T                   |
++---------------------+
+| 1970-01-01 00:00:00 |
++---------------------+
+(1 row)
+
+!ok
+
+# [CALCITE-1188] NullPointerException in EXTRACT with WHERE ... IN clause if field has null
value
+select extract(YEAR from "sqlTimestamp") Y
+from "everyTypes"
+where extract(YEAR from "sqlTimestamp") IN (1969, 1970);
++------+
+| Y    |
++------+
+| 1970 |
++------+
+(1 row)
+
+!ok
+
 !if (false) {
 # [CALCITE-2032] Error when implicitly converting character literal to date literal
 select *


Mime
View raw message