Skip to content

Commit

Permalink
use OffsetBuffer::new_unchecked in convert_to_state.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Jan 27, 2025
1 parent d8d9a19 commit b5144b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions datafusion/functions-aggregate/src/median.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
// Build offsets
let mut offsets = Vec::with_capacity(self.group_values.len() + 1);
offsets.push(0);
let mut cur_len = 0;
let mut cur_len = 0_i32;
for group_value in &emit_group_values {
cur_len += group_value.len() as i32;
offsets.push(cur_len);
Expand Down Expand Up @@ -443,8 +443,9 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
.with_data_type(self.data_type.clone());

// `offsets` in `ListArray`, each row as a list element
assert!(input_array.len() <= i32::MAX as usize);
let offsets = (0..=input_array.len() as i32).collect::<Vec<_>>();
let offsets = OffsetBuffer::new(ScalarBuffer::from(offsets));
let offsets = unsafe { OffsetBuffer::new_unchecked(ScalarBuffer::from(offsets)) };

// `nulls` for converted `ListArray`
let nulls = filtered_null_mask(opt_filter, input_array);
Expand Down

0 comments on commit b5144b8

Please sign in to comment.