clintropolis commented on a change in pull request #11949:
URL: https://github.com/apache/druid/pull/11949#discussion_r752856348



##########
File path: 
sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java
##########
@@ -262,6 +306,17 @@ public RelDataType inferReturnType(SqlOperatorBinding 
sqlOperatorBinding)
                   "'" + aggregatorType.name() + "(expr, maxBytesPerString)'\n",
                   OperandTypes.ANY,
                   OperandTypes.and(OperandTypes.NUMERIC, OperandTypes.LITERAL)
+              ),
+              OperandTypes.sequence(
+                  "'" + aggregatorType.name() + "(expr, timeColumn)'\n",
+                  OperandTypes.ANY,
+                  OperandTypes.ANY

Review comment:
       any seems a bit permissive, since i think this probably needs to be a 
long?

##########
File path: 
sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java
##########
@@ -206,19 +195,74 @@ public Aggregation toDruidAggregation(
       );
     }
 
+    final String fieldName = getColumnName(plannerContext, 
virtualColumnRegistry, args.get(0), rexNodes.get(0));
+
+    final AggregatorFactory theAggFactory;
+    switch (args.size()) {
+      case 1:
+        theAggFactory = aggregatorType.createAggregatorFactory(aggregatorName, 
fieldName, null, outputType, -1);
+        break;
+      case 2:
+        if (outputType.anyOf(ValueType.STRING, ValueType.COMPLEX)) {

Review comment:
       nit: might be worth a comment that this is to handle 2nd argument as 
either byte size or time column, depending on the input type to make it a bit 
easier to make sense of what's going on here.
   
   I think you could also potentially just make this check be 
`!outputType.isNumeric()` since those are fixed width and don't have a size 
limit

##########
File path: 
processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java
##########
@@ -256,20 +259,28 @@ public String getFieldName()
     return fieldName;
   }
 
+  @JsonProperty
+  public String getTimeColumn()
+  {
+    return timeColumn;
+  }
+
   @Override
   public List<String> requiredFields()
   {
-    return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName);
+    return Arrays.asList(timeColumn, fieldName);
   }
 
   @Override
   public byte[] getCacheKey()
   {
     byte[] fieldNameBytes = StringUtils.toUtf8(fieldName);
+    byte[] timeColumnBytes = StringUtils.toUtf8(timeColumn);

Review comment:
       nit: maybe a good opportunity to switch to `CacheKeyBuilder`? (same 
comment for all other aggs)




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to