Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jul 5, 2023
1 parent c041ecc commit f973a65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
6 changes: 3 additions & 3 deletions datafusion/core/src/physical_plan/aggregates/row_hash2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl GroupedHashAggregateStream2 {
AggregateMode::Partial | AggregateMode::Single => {
acc.update_batch(
values,
&group_indices,
group_indices,
opt_filter,
total_num_groups,
)?;
Expand All @@ -473,7 +473,7 @@ impl GroupedHashAggregateStream2 {
// use merge
acc.merge_batch(
values,
&group_indices,
group_indices,
opt_filter,
total_num_groups,
)?;
Expand Down Expand Up @@ -501,7 +501,7 @@ impl GroupedHashAggregateStream2 {
}

// First output rows are the groups
let groups_rows = self.group_values.iter().map(|owned_row| owned_row);
let groups_rows = self.group_values.iter();

let mut output: Vec<ArrayRef> = self.row_converter.convert_rows(groups_rows)?;

Expand Down
27 changes: 13 additions & 14 deletions datafusion/physical-expr/src/aggregate/average.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,19 @@ impl AggregateExpr for Avg {
fn groups_accumulator_supported(&self) -> bool {
use DataType::*;

match &self.sum_data_type {
Int8
| Int16
| Int32
| Int64
| UInt8
| UInt16
| UInt32
| UInt64
| Float32
| Float64
| Decimal128(_, _) => true,
_ => false,
}
matches!(
&self.sum_data_type,
Int8 | Int16
| Int32
| Int64
| UInt8
| UInt16
| UInt32
| UInt64
| Float32
| Float64
| Decimal128(_, _)
)
}

fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ impl GroupsAccumulatorAdapter {
// RecordBatch(es)
let iter = groups_with_rows.iter().zip(offsets.windows(2));

for (group_idx, offsets) in iter {
let state = &mut self.states[*group_idx as usize];
for (&group_idx, offsets) in iter {
let state = &mut self.states[group_idx];
let size_pre = state.size();

let values_to_accumulate =
slice_and_maybe_filter(&values, opt_filter.as_ref(), &offsets)?;
slice_and_maybe_filter(&values, opt_filter.as_ref(), offsets)?;
(f)(state.accumulator.as_mut(), &values_to_accumulate)?;

// clear out the state
Expand Down Expand Up @@ -267,7 +267,7 @@ impl GroupsAccumulator for GroupsAccumulatorAdapter {

for state in states {
let accumulator_state = state.accumulator.state()?;
results.resize_with(accumulator_state.len(), || vec![]);
results.resize_with(accumulator_state.len(), Vec::new);
for (idx, state_val) in accumulator_state.into_iter().enumerate() {
results[idx].push(state_val);
}
Expand All @@ -276,7 +276,7 @@ impl GroupsAccumulator for GroupsAccumulatorAdapter {
// create an array for each intermediate column
let arrays = results
.into_iter()
.map(|state| ScalarValue::iter_to_array(state))
.map(ScalarValue::iter_to_array)
.collect::<Result<Vec<_>>>()?;

// double check each array has the same length (aka the
Expand Down Expand Up @@ -348,7 +348,7 @@ pub(crate) fn slice_and_maybe_filter(
sliced_arrays
.iter()
.map(|array| {
compute::filter(array, &filter_array).map_err(DataFusionError::ArrowError)
compute::filter(array, filter_array).map_err(DataFusionError::ArrowError)
})
.collect()
} else {
Expand Down
7 changes: 2 additions & 5 deletions datafusion/physical-expr/src/aggregate/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,8 @@ where

let sums = adjust_output_array(&self.sum_data_type, sums)?;

let counts = vec![0 as u64; sums.len()];
let counts = Arc::new(PrimitiveArray::<UInt64Type>::new(
counts.into(),
nulls.clone(),
));
let counts = vec![0_u64; sums.len()];
let counts = Arc::new(PrimitiveArray::<UInt64Type>::new(counts.into(), nulls));

// TODO: Sum expects sum/count array, but count is not needed
Ok(vec![sums.clone() as ArrayRef, counts as ArrayRef])
Expand Down

0 comments on commit f973a65

Please sign in to comment.