xiangfu0 commented on code in PR #19988:
URL: https://github.com/apache/pinot/pull/19988#discussion_r4366204631
##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotAggregateTypeArgumentRewriteRule.java:
##########
@@ -143,6 +171,12 @@ private static String getDataTypeArgument(AggregateCall
aggCall, RelNode input)
case DOUBLE:
return "DOUBLE";
case DECIMAL:
+ // The planner types an array of DECIMAL with scale 0 as INT_ARRAY or
LONG_ARRAY, see
+ // RelToPlanNodeConverter.resolveDecimal
+ if (name.equals(AggregationFunctionType.ARRAYAGG.name()) &&
dataType.getScale() == 0
+ && dataType.getPrecision() <= 38) {
+ return dataType.getPrecision() <= 10 ? "INT" : "LONG";
Review Comment:
Nice that precision <= 38 now follows `resolveDecimal`. Just noting the
remaining edge: a scale-0 DECIMAL with precision > 38 falls through to
`BIG_DECIMAL` below, while `resolveDecimal` maps that array to `DOUBLE_ARRAY`,
so the accumulator and the declared column type disagree. It matches the
explicit form's behavior today, so not a blocker.
##########
pinot-core/src/main/java/org/apache/pinot/core/query/optimizer/statement/AggregateFunctionRewriteOptimizer.java:
##########
@@ -134,6 +139,45 @@ private static void addDataTypeArgument(Function function,
String functionName,
functionName, fieldSpec.isSingleValueField() ? "" : "multi-value ",
fieldSpec.getDataType()));
}
+ /// Matches ARRAY_AGG(column) and ARRAY_AGG(column, isDistinct); a string
second argument is the explicit data type.
+ private static boolean isArrayAggWithoutDataType(Function function) {
Review Comment:
Worth keeping in mind: single-stage only rewrites a plain column operand,
while the multi-stage rule handles any expression. So `ARRAY_AGG(trim(col))`
without a type works on MSE but errors here. It's documented in the PR, so fine
to leave; just worth making sure the user-facing error stays clear.
--
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]