Repository navigation
Commit 8a92281
authored
Refine and document AggregateExec metrics (apache#24757)
## Which issue does this PR close?
* Part of apache#23570
## Rationale for this change
Aggregate-specific metrics are a user-visible observability surface in
`EXPLAIN ANALYZE`, but their phase boundaries and relationship to
individual aggregate expressions need to be clear and consistent.
In particular, users should be able to understand what each aggregate
timer measures, map indexed metrics such as `agg_expr_0_arguments_time`
back to the corresponding expression in the operator's `aggr=[...]`
list, and understand which metrics are available on different grouped
aggregation paths without reading the implementation.
This PR also tightens the timing boundaries of the grouped aggregate
metrics so that the documented metrics correspond more directly to the
work they describe.
## What changes are included in this PR?
* Documents `AggregateExec` operator-level and per-aggregate metrics,
including their phase boundaries, indexed naming convention, aggregate
expression labels, visibility, and path-specific coverage.
* Groups aggregate timing into explicit phases for:
* group-key preparation,
* aggregate argument and filter evaluation,
* accumulator `update` / `merge` operations, and
* output emission.
* Ensures accumulator `aggregation_time` measures a single interval
containing the relevant accumulator operations rather than accumulating
overlapping/prefix timing.
* Includes group interning and ordering setup in
`time_calculating_group_ids`.
* Includes collectively evaluated aggregate filters in
`aggregate_arguments_time`.
* Adds `topk_maintenance_time` for Grouped TopK priority-map maintenance
and avoids registering `aggregation_time` for that accumulator-free
path.
* Times grouped output materialization consistently with
`emitting_time`.
* Adds `EXPLAIN ANALYZE` coverage demonstrating how indexed
per-aggregate metrics map to multiple aggregate expressions and how
expression labels appear in verbose output.
## Are these changes tested?
Yes.
The patch adds and updates tests that verify:
* `EXPLAIN ANALYZE` reports `agg_expr_0_arguments_time`,
`agg_expr_1_arguments_time`, and `agg_expr_2_arguments_time` for a query
containing `SUM(c5)`, `SUM(c6)`, and `COUNT(c7)`.
* `EXPLAIN ANALYZE VERBOSE` associates those indexed metrics with the
corresponding rendered aggregate expressions.
* Grouped TopK reports `topk_maintenance_time` and
`time_calculating_group_ids` while not registering `aggregation_time`.
* Regular aggregate paths do not report `topk_maintenance_time`.
* Aggregate execution without grouped emission does not report
`emitting_time`.
* `GroupByMetrics::new_topk` does not register `aggregation_time`.
## Are there any user-facing changes?
Yes. Aggregate metrics shown through `EXPLAIN ANALYZE` are clarified and
their timing boundaries are made more consistent.
The metrics documentation now describes the `AggregateExec`
operator-level metrics and per-expression timer phases, explains how
indexed metrics map to aggregate expressions, and documents
path-specific differences such as Grouped TopK and non-grouped
aggregation.
These are observability and documentation changes; this PR does not
introduce a public API change.
## LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated
content has been manually reviewed.1 parent 84ccbb1 commit 8a92281
9 files changed
Lines changed: 706 additions & 410 deletions
File tree
- datafusion
- core/tests/sql
- physical-plan/src/aggregates
- aggregate_hash_table
- group_values
- docs/source/user-guide
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1064 | 1064 | | |
1065 | 1065 | | |
1066 | 1066 | | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1067 | 1108 | | |
1068 | 1109 | | |
1069 | 1110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
| |||
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | 217 | | |
219 | | - | |
220 | | - | |
221 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
222 | 224 | | |
223 | 225 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| |||
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| |||
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
| 342 | + | |
337 | 343 | | |
338 | 344 | | |
339 | 345 | | |
340 | 346 | | |
341 | 347 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
350 | 359 | | |
351 | 360 | | |
352 | 361 | | |
| |||
401 | 410 | | |
402 | 411 | | |
403 | 412 | | |
| 413 | + | |
404 | 414 | | |
405 | 415 | | |
406 | 416 | | |
407 | 417 | | |
408 | 418 | | |
409 | 419 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
427 | 434 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
435 | 438 | | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
441 | 454 | | |
442 | 455 | | |
443 | 456 | | |
444 | 457 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
455 | 478 | | |
456 | 479 | | |
457 | 480 | | |
| |||
0 commit comments