diff --git a/datafusion/core/src/physical_plan/aggregates/order/full.rs b/datafusion/core/src/physical_plan/aggregates/order/full.rs index 41bcc33b0849..c957e2a6af3c 100644 --- a/datafusion/core/src/physical_plan/aggregates/order/full.rs +++ b/datafusion/core/src/physical_plan/aggregates/order/full.rs @@ -110,7 +110,7 @@ impl GroupOrderingFull { State::InProgress { current } => { // shift down by n assert!(*current >= n); - *current = *current - n; + *current -= n; self.hashes.drain(0..n); } State::Complete { .. } => panic!("invalid state: complete"), diff --git a/datafusion/core/src/physical_plan/aggregates/order/partial.rs b/datafusion/core/src/physical_plan/aggregates/order/partial.rs index b7e1fcac888a..96f9353e9372 100644 --- a/datafusion/core/src/physical_plan/aggregates/order/partial.rs +++ b/datafusion/core/src/physical_plan/aggregates/order/partial.rs @@ -69,9 +69,10 @@ pub(crate) struct GroupOrderingPartial { } /// Tracks the state of the the grouping -#[derive(Debug)] +#[derive(Debug, Default)] enum State { /// Taken to potentially be updated. + #[default] Taken, /// Have seen no input yet @@ -92,13 +93,6 @@ enum State { Complete, } -// Implement default so the state can be temporarily taken via `std::mem::take` -impl Default for State { - fn default() -> Self { - State::Taken - } -} - impl GroupOrderingPartial { pub fn try_new( input_schema: &Schema, @@ -176,9 +170,9 @@ impl GroupOrderingPartial { } => { // shift indexes down by n assert!(*current >= n); - *current = *current - n; + *current -= n; assert!(*current_sort >= n); - *current_sort = *current_sort - n; + *current_sort -= n; // Note sort_key stays the same, we are just translating group indexes self.hashes.drain(0..n); } diff --git a/datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs b/datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs index 1acf4214c521..56d09f2a9ab6 100644 --- a/datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs +++ b/datafusion/physical-expr/src/aggregate/groups_accumulator/mod.rs @@ -112,11 +112,11 @@ pub trait GroupsAccumulator: Send { /// each group, and `evaluate` will produce that running sum as /// its output for all groups, in group_index order /// - /// If `emit_to`` is [`Emit::All`], the accumulator should return all + /// If `emit_to`` is [`EmitTo::All`], the accumulator should return all /// groups and release / reset its internal state equivalent to /// when it was first created. /// - /// If `emit_to` is [`Emit::First`], only the first `first` groups + /// If `emit_to` is [`EmitTo::First`], only the first `first` groups /// should be emitted and the state for those first groups. State /// for the remaining groups must be retained for future use. The /// group_indices on subsequent calls to `update_batch` or