Skip to content

Commit e305353

Browse files
authored
Enrich GroupedHashAggregateStream name to ease debugging Resources exhausted errors (apache#16152)
* Enrich GroupedHashAggregateStream name to ease debugging Resources exhausted errors * Use human_display * clippy
1 parent 17fe504 commit e305353

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

datafusion/core/tests/memory_limit/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,19 @@ async fn oom_with_tracked_consumer_pool() {
408408
.await
409409
}
410410

411+
#[tokio::test]
412+
async fn oom_grouped_hash_aggregate() {
413+
TestCase::new()
414+
.with_query("SELECT COUNT(*), SUM(request_bytes) FROM t GROUP BY host")
415+
.with_expected_errors(vec![
416+
"Failed to allocate additional",
417+
"GroupedHashAggregateStream[0] (count(1), sum(t.request_bytes))",
418+
])
419+
.with_memory_limit(1_000)
420+
.run()
421+
.await
422+
}
423+
411424
/// For regression case: if spilled `StringViewArray`'s buffer will be referenced by
412425
/// other batches which are also need to be spilled, then the spill writer will
413426
/// repeatedly write out the same buffer, and after reading back, each batch's size

datafusion/physical-plan/src/aggregates/row_hash.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,12 @@ impl GroupedHashAggregateStream {
529529
})
530530
.collect();
531531

532-
let name = format!("GroupedHashAggregateStream[{partition}]");
532+
let agg_fn_names = aggregate_exprs
533+
.iter()
534+
.map(|expr| expr.human_display())
535+
.collect::<Vec<_>>()
536+
.join(", ");
537+
let name = format!("GroupedHashAggregateStream[{partition}] ({agg_fn_names})");
533538
let reservation = MemoryConsumer::new(name)
534539
.with_can_spill(true)
535540
.register(context.memory_pool());

0 commit comments

Comments
 (0)