File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
datafusion/functions-aggregate/src Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -382,7 +382,7 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
382382 // Build offsets
383383 let mut offsets = Vec :: with_capacity ( self . group_values . len ( ) + 1 ) ;
384384 offsets. push ( 0 ) ;
385- let mut cur_len = 0 ;
385+ let mut cur_len = 0_i32 ;
386386 for group_value in & emit_group_values {
387387 cur_len += group_value. len ( ) as i32 ;
388388 offsets. push ( cur_len) ;
@@ -443,8 +443,10 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
443443 . with_data_type ( self . data_type . clone ( ) ) ;
444444
445445 // `offsets` in `ListArray`, each row as a list element
446+ assert ! ( input_array. len( ) <= i32 :: MAX as usize ) ;
446447 let offsets = ( 0 ..=input_array. len ( ) as i32 ) . collect :: < Vec < _ > > ( ) ;
447- let offsets = OffsetBuffer :: new ( ScalarBuffer :: from ( offsets) ) ;
448+ // Safety: all checks in `OffsetBuffer::new` are ensured to pass
449+ let offsets = unsafe { OffsetBuffer :: new_unchecked ( ScalarBuffer :: from ( offsets) ) } ;
448450
449451 // `nulls` for converted `ListArray`
450452 let nulls = filtered_null_mask ( opt_filter, input_array) ;
You can’t perform that action at this time.
0 commit comments