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 2020/09/02 22:54:21 UTC

[GitHub] [druid] suneet-s commented on a change in pull request #10332: Fix stringFirst/stringLast rollup during ingestion

suneet-s commented on a change in pull request #10332:
URL: https://github.com/apache/druid/pull/10332#discussion_r482569314



##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java
##########
@@ -227,14 +257,14 @@ public Aggregation toDruidAggregation(
           aggregatorType.name(),
           null,
           SqlKind.OTHER_FUNCTION,
-          ReturnTypes.ARG0,
+          new EarliestLatestReturnTypeInference(0),

Review comment:
       We should reuse this instance across all calls to `toDruidAggregation`

##########
File path: integration-tests/src/test/resources/indexer/wikipedia_merge_index_task.json
##########
@@ -0,0 +1,70 @@
+{
+    "type": "index",
+    "spec": {
+        "dataSchema": {
+            "dataSource": "%%DATASOURCE%%",
+            "metricsSpec": [
+                {
+                    "type": "count",
+                    "name": "count"
+                },
+                {
+                    "type": "doubleSum",
+                    "name": "added",
+                    "fieldName": "added"
+                },
+                {
+                    "type": "doubleSum",
+                    "name": "deleted",
+                    "fieldName": "deleted"
+                },
+                {
+                    "type": "doubleSum",
+                    "name": "delta",
+                    "fieldName": "delta"
+                },
+                {
+                    "type": "stringFirst",
+                    "name": "first_user",
+                    "fieldName": "user"
+                },
+                {
+                    "type": "stringLast",
+                    "name": "last_user",
+                    "fieldName": "user"
+                }

Review comment:
       Can we add these to `wikipedia_index_task.json` instead. This way we don't need to run another integration test which can be quite slow
   
   You will probably want to do something very similar to #9277

##########
File path: processing/src/main/java/org/apache/druid/query/aggregation/first/StringFirstAggregatorFactory.java
##########
@@ -188,7 +188,7 @@ public Comparator getComparator()
   @Override
   public Object combine(Object lhs, Object rhs)
   {
-    return TIME_COMPARATOR.compare(lhs, rhs) > 0 ? lhs : rhs;
+    return TIME_COMPARATOR.compare(lhs, rhs) < 0 ? lhs : rhs;

Review comment:
       wow! Is there a test for this somewhere?

##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java
##########
@@ -227,14 +257,14 @@ public Aggregation toDruidAggregation(
           aggregatorType.name(),
           null,
           SqlKind.OTHER_FUNCTION,
-          ReturnTypes.ARG0,
+          new EarliestLatestReturnTypeInference(0),
           InferTypes.RETURN_TYPE,
           OperandTypes.or(
               OperandTypes.NUMERIC,
               OperandTypes.BOOLEAN,
               OperandTypes.sequence(
                   "'" + aggregatorType.name() + "(expr, maxBytesPerString)'\n",
-                  OperandTypes.STRING,
+                  OperandTypes.ANY,

Review comment:
       shouldn't this remain `STRING` ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



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