Skip to content

Commit e3c11e7

Browse files
committed
feat(metrics): require RefUnwindSafe for AggregateMetric and add compile‑time test for DistinctArrayAggAccumulator
- Updated `AggregateMetric` to implement the `RefUnwindSafe` trait, ensuring safe reference semantics during unwind operations. - Added a compile‑time test (`distinct_array_agg_accumulator_unwindsafe`) that verifies `DistinctArrayAggAccumulator` maintains both `UnwindSafe` and `RefUnwindSafe` guarantees, preventing panics in error‑recovery scenarios.
1 parent b6e9450 commit e3c11e7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎datafusion/expr-common/src/accumulator.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::time::Duration;
2727
///
2828
/// Aggregate implementations use this interface for optional internal
2929
/// subphases. The execution engine owns metric registration and aggregation.
30-
pub trait AggregateMetric: Debug + Send + Sync {
30+
pub trait AggregateMetric: Debug + Send + Sync + std::panic::RefUnwindSafe {
3131
/// Adds elapsed time to this metric.
3232
fn add_duration(&self, duration: Duration);
3333
}

‎datafusion/functions-aggregate/src/array_agg.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,14 @@ mod tests {
14851485
use datafusion_physical_expr::PhysicalExpr;
14861486
use datafusion_physical_expr::expressions::Column;
14871487

1488+
#[test]
1489+
fn distinct_accumulator_preserves_unwind_auto_traits() {
1490+
fn assert_unwind_traits<T: std::panic::UnwindSafe + std::panic::RefUnwindSafe>() {
1491+
}
1492+
1493+
assert_unwind_traits::<DistinctArrayAggAccumulator>();
1494+
}
1495+
14881496
#[test]
14891497
fn distinct_accumulator_size_includes_metric_handle() -> Result<()> {
14901498
let accumulator =

0 commit comments

Comments
 (0)