diff --git a/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs b/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs index 5b9a0ef9df2ec..50380c9406784 100644 --- a/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs +++ b/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs @@ -141,7 +141,7 @@ where values: &[ArrayRef], opt_filter: Option<&BooleanArray>, ) -> Result> { - let values = values[0].as_primitive::(); + let values = values[0].as_primitive::().clone(); // Initializing state with starting values let initial_state = @@ -164,11 +164,11 @@ where let (dt, values_buf, original_nulls) = values.clone().into_parts(); let nulls_buf = NullBuffer::union(original_nulls.as_ref(), Some(&filter_nulls)); - &PrimitiveArray::::new(values_buf, nulls_buf).with_data_type(dt) + PrimitiveArray::::new(values_buf, nulls_buf).with_data_type(dt) } }; - let state_values = compute::binary_mut(initial_state, values, |mut x, y| { + let state_values = compute::binary_mut(initial_state, &values, |mut x, y| { (self.prim_fn)(&mut x, y); x });