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

[GitHub] gianm closed pull request #6616: Fix bugs in ExprEval and GroupByQuery

gianm closed pull request #6616: Fix bugs in ExprEval and GroupByQuery
URL: https://github.com/apache/incubator-druid/pull/6616
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 20982e6b0f9..fb28d862e64 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 static ExprEval of(double doubleValue)
 
   public static ExprEval of(@Nullable String stringValue)
   {
+    if (stringValue == null) {
+      return StringExprEval.OF_NULL;
+    }
     return new StringExprEval(stringValue);
   }
 
@@ -180,7 +183,11 @@ public final ExprEval castTo(ExprType castTo)
         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 final ExprEval castTo(ExprType castTo)
     {
       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 Expr toExpr()
 
   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 abd5c9a5d6f..b28dde530d6 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 @@ private static void verifyOutputNames(
 
   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 Builder(Builder builder)
       postAggregatorSpecs = builder.postAggregatorSpecs;
       havingSpec = builder.havingSpec;
       limitSpec = builder.limitSpec;
+      subtotalsSpec = copySubtotalSpec(builder.subtotalsSpec);
       postProcessingFn = builder.postProcessingFn;
       limit = builder.limit;
       orderByColumnSpecs = new ArrayList<>(builder.orderByColumnSpecs);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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