Skip to content

Commit c56a7ab

Browse files
authored
Add per-aggregate metrics to non-grouped AggregateStream (apache#24706)
## Which issue does this PR close? * Part of apache#23570 ## Rationale for this change Non-grouped aggregation can spend significant time evaluating aggregate arguments and filters, updating or merging accumulators, and producing partial or final accumulator output. `AggregateStream` did not expose per-aggregate timing for this work, making it difficult to identify which aggregate expression or phase contributes to execution time. This change adds aggregate-specific phase timing to non-grouped aggregation using the same metric naming and aggregate labels as the grouped aggregation path, so expressions such as `SUM(a)` and `SUM(b)` can be distinguished. ## What changes are included in this PR? * Adds per-aggregate timing for argument and filter evaluation in `AggregateStream`. * Adds timing around accumulator `update_batch` and `merge_batch` calls according to the aggregate input mode. * Adds timing around accumulator `state` emission for partial output modes and `evaluate` for final output modes. * Selects the accumulator metric phases exposed for each `AggregateMode`. * Reuses `AggregateArgumentMetrics`, `AggregateAccumulatorMetrics`, `AccumulatorPhase`, and aggregate metric labels from the grouped aggregation metrics infrastructure. * Keeps the existing baseline elapsed-compute timing around aggregate processing and finalization. ## Are these changes tested? Yes. This PR adds: * `accumulator_phases_match_aggregate_mode`, which verifies the expected accumulator phases for all six aggregate modes. * `aggregate_stream_reports_per_aggregate_metrics`, which verifies that a single-stage non-grouped aggregate with `SUM(a)` and `SUM(b)` reports distinct `arguments`, `update`, and `evaluate` metrics and does not report unused `merge` or `state` phases. * `aggregate_stream_reports_partial_and_final_phases`, which verifies that partial aggregation reports `arguments`, `update`, and `state`, while final aggregation reports `arguments`, `merge`, and `evaluate`. The tests also verify that same-function aggregates over different columns are distinguishable by their aggregate labels. ## Are there any user-facing changes? `AggregateStream` metrics now expose per-aggregate-expression timing for the phases executed by non-grouped aggregation. This provides additional observability for consumers of execution metrics, including `EXPLAIN ANALYZE`. There are no public API changes shown in this patch. ## LLM-generated code disclosure This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.
1 parent f60f705 commit c56a7ab

1 file changed

Lines changed: 309 additions & 26 deletions

File tree

0 commit comments

Comments
 (0)