kosiew opened a new pull request, #24706: URL: https://github.com/apache/datafusion/pull/24706
## Which issue does this PR close? * Part of #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. -- 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]
