You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by gi...@apache.org on 2018/11/14 23:19:30 UTC

[incubator-druid] branch 0.13.0-incubating updated: Fix bugs in ExprEval and GroupByQuery (#6616)

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

gian pushed a commit to branch 0.13.0-incubating
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/0.13.0-incubating by this push:
     new 17272d1  Fix bugs in ExprEval and GroupByQuery (#6616)
17272d1 is described below

commit 17272d1054de959a04cc046996171dea14d54646
Author: Roman Leventov <le...@gmail.com>
AuthorDate: Thu Nov 15 00:19:24 2018 +0100

    Fix bugs in ExprEval and GroupByQuery (#6616)
---
 .../main/java/org/apache/druid/math/expr/ExprEval.java  | 17 +++++++++++++++--
 .../org/apache/druid/query/groupby/GroupByQuery.java    | 10 ++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/src/main/java/org/apache/druid/math/expr/ExprEval.java b/common/src/main/java/org/apache/druid/math/expr/ExprEval.java
index 20982e6..fb28d86 100644
--- a/common/src/main/java/org/apache/druid/math/expr/ExprEval.java
+++ b/common/src/main/java/org/apache/druid/math/expr/ExprEval.java
@@ -52,6 +52,9 @@ public abstract class ExprEval<T>
 
   public static ExprEval of(@Nullable String stringValue)
   {
+    if (stringValue == null) {
+      return StringExprEval.OF_NULL;
+    }
     return new StringExprEval(stringValue);
   }
 
@@ -180,7 +183,11 @@ public abstract class ExprEval<T>
         case DOUBLE:
           return this;
         case LONG:
-          return ExprEval.of(value == null ? null : asLong());
+          if (value == null) {
+            return ExprEval.ofLong(null);
+          } else {
+            return ExprEval.of(asLong());
+          }
         case STRING:
           return ExprEval.of(asString());
       }
@@ -218,7 +225,11 @@ public abstract class ExprEval<T>
     {
       switch (castTo) {
         case DOUBLE:
-          return ExprEval.of(value == null ? null : asDouble());
+          if (value == null) {
+            return ExprEval.ofDouble(null);
+          } else {
+            return ExprEval.of(asDouble());
+          }
         case LONG:
           return this;
         case STRING:
@@ -236,6 +247,8 @@ public abstract class ExprEval<T>
 
   private static class StringExprEval extends ExprEval<String>
   {
+    private static final StringExprEval OF_NULL = new StringExprEval(null);
+
     private Number numericVal;
 
     private StringExprEval(@Nullable String value)
diff --git a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java
index abd5c9a..b28dde5 100644
--- a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java
+++ b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java
@@ -737,6 +737,15 @@ public class GroupByQuery extends BaseQuery<Row>
 
   public static class Builder
   {
+    @Nullable
+    private static List<List<String>> copySubtotalSpec(@Nullable List<List<String>> subtotalsSpec)
+    {
+      if (subtotalsSpec == null) {
+        return null;
+      }
+      return subtotalsSpec.stream().map(ArrayList::new).collect(Collectors.toList());
+    }
+
     private DataSource dataSource;
     private QuerySegmentSpec querySegmentSpec;
     private VirtualColumns virtualColumns;
@@ -788,6 +797,7 @@ public class GroupByQuery extends BaseQuery<Row>
       postAggregatorSpecs = builder.postAggregatorSpecs;
       havingSpec = builder.havingSpec;
       limitSpec = builder.limitSpec;
+      subtotalsSpec = copySubtotalSpec(builder.subtotalsSpec);
       postProcessingFn = builder.postProcessingFn;
       limit = builder.limit;
       orderByColumnSpecs = new ArrayList<>(builder.orderByColumnSpecs);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org