Skip to content

Support ARRAY_AGG without a data type - #19988

Open
xiangfu0 wants to merge 1 commit into
xiangfu0/agg-rewrite/01-first-last-with-timefrom
xiangfu0/agg-rewrite/02-array-agg
Open

xiangfu0 wants to merge 1 commit into
xiangfu0/agg-rewrite/01-first-last-with-timefrom
xiangfu0/agg-rewrite/02-array-agg

Conversation

@xiangfu0

Copy link
Copy Markdown
Contributor

Summary

Supports ARRAY_AGG(expr) and ARRAY_AGG(expr, isDistinct) without the explicit data type argument.

Stacked on #19986; will be retargeted to master once it merges.

How

Both engines rewrite the call to the existing explicit form ARRAY_AGG(expr, 'dataType'[, isDistinct]), using the type of expr, or its element type for a multi-value input. A JSON column maps to STRING in both engines.

  • Single-stage: AggregateFunctionRewriteOptimizer, for column operands.
  • Multi-stage: PinotAggregateTypeArgumentRewriteRule, for any expression. Validation rejects types that the explicit form does not support.

The explicit form is unchanged: a string second argument is the data type. Distinct ARRAY_AGG is still served from the star-tree.

Tests

  • AggregateFunctionRewriteOptimizerTest
  • ArrayAggQueriesTest, ArrayAggMvQueriesTest, ArrayAggStarTreeQueriesTest
  • Multi-stage plans in AggregatePlans.json, runtime queries in UDFAggregates.json

@xiangfu0 xiangfu0 added query Related to query processing multi-stage Related to the multi-stage query engine feature New functionality aggregation Related to aggregation functions and operations labels Oct 21, 2026
@xiangfu0
xiangfu0 force-pushed the xiangfu0/agg-rewrite/01-first-last-with-time branch from 2b49933 to 7725620 Compare October 21, 2026 08:21
@xiangfu0
xiangfu0 force-pushed the xiangfu0/agg-rewrite/02-array-agg branch from b80d110 to a23a7fd Compare October 21, 2026 22:10
Both query engines rewrite ARRAY_AGG(expression) and
ARRAY_AGG(expression, isDistinct) to the explicit form
ARRAY_AGG(expression, 'dataType'[, isDistinct]) with the type of the
expression, or its element type for a multi-value input:
AggregateFunctionRewriteOptimizer for a column in the single-stage engine and
PinotAggregateTypeArgumentRewriteRule in the multi-stage engine.
@xiangfu0
xiangfu0 force-pushed the xiangfu0/agg-rewrite/01-first-last-with-time branch from ca99413 to 2dab204 Compare October 22, 2026 09:28
@xiangfu0
xiangfu0 force-pushed the xiangfu0/agg-rewrite/02-array-agg branch from a23a7fd to 4d7e69f Compare October 22, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aggregation Related to aggregation functions and operations feature New functionality multi-stage Related to the multi-stage query engine query Related to query processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant