calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcama...@apache.org
Subject calcite git commit: [CALCITE-1770] Druid adapter: CAST(NULL AS ...) gives NPE (Slim Bouguerra)
Date Sat, 13 May 2017 09:05:56 GMT
Repository: calcite
Updated Branches:
  refs/heads/master e046be23d -> ea994131c


[CALCITE-1770] Druid adapter: CAST(NULL AS ...) gives NPE (Slim Bouguerra)

Avoid pushing literal NULL values to Druid.

Close apache/calcite#448


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

Branch: refs/heads/master
Commit: ea994131cd6d109ff7edf5e61754104e2b8619be
Parents: e046be2
Author: Slim Bouguerra <slim.bouguerra@gmail.com>
Authored: Fri May 12 10:58:31 2017 -0700
Committer: Jesus Camacho Rodriguez <jcamacho@apache.org>
Committed: Sat May 13 09:50:16 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/calcite/adapter/druid/DruidQuery.java    | 7 ++-----
 .../test/java/org/apache/calcite/test/DruidAdapterIT.java    | 8 ++++++--
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/ea994131/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
----------------------------------------------------------------------
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
index 81e94dd..c25262e 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
@@ -207,8 +207,9 @@ public class DruidQuery extends AbstractRelNode implements BindableRel
{
   boolean isValidFilter(RexNode e, boolean boundedComparator) {
     switch (e.getKind()) {
     case INPUT_REF:
-    case LITERAL:
       return true;
+    case LITERAL:
+      return ((RexLiteral) e).getValue() != null;
     case AND:
     case OR:
     case NOT:
@@ -959,10 +960,6 @@ public class DruidQuery extends AbstractRelNode implements BindableRel
{
       case CAST:
         return tr(e, 0, set);
       case LITERAL:
-        if (((RexLiteral) e).getValue3() == null) {
-          // Druid considers null is equivalent to empty.
-          return "";
-        }
         return ((RexLiteral) e).getValue3().toString();
       case FLOOR:
       case EXTRACT:

http://git-wip-us.apache.org/repos/asf/calcite/blob/ea994131/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
----------------------------------------------------------------------
diff --git a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
index 63a4bd9..2b639c8 100644
--- a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
+++ b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
@@ -2097,8 +2097,12 @@ public class DruidAdapterIT {
         + "from \"foodmart\"\n"
         + "where \"product_id\" = cast(NULL as varchar)\n"
         + "group by \"product_id\"";
-    String druidQuery = "'filter':{'type':'selector','dimension':'product_id','value':''}";
-    sql(sql).queryContains(druidChecker(druidQuery));
+    final String plan = "PLAN=EnumerableInterpreter\n"
+        + "  BindableAggregate(group=[{0}])\n"
+        + "    BindableFilter(condition=[=($0, null)])\n"
+        + "      DruidQuery(table=[[foodmart, foodmart]], "
+        + "intervals=[[1900-01-09T00:00:00.000/2992-01-10T00:00:00.000]], projects=[[$1]])";
+    sql(sql).explainContains(plan);
   }
 
   @Test public void testFalseFilter() {


Mime
View raw message