File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -322,7 +322,11 @@ fn hash_fixed_list_array(
322322) -> Result < ( ) > {
323323 let values = Arc :: clone ( array. values ( ) ) ;
324324 let value_len = array. value_length ( ) ;
325- let offset_size = value_len as usize / array. len ( ) ;
325+ let offset_size = if array. len ( ) == 0 {
326+ 0
327+ } else {
328+ value_len as usize / array. len ( )
329+ } ;
326330 let nulls = array. nulls ( ) ;
327331 let mut values_hashes = vec ! [ 0u64 ; values. len( ) ] ;
328332 create_hashes ( & [ values] , random_state, & mut values_hashes) ?;
@@ -454,6 +458,16 @@ mod tests {
454458 Ok ( ( ) )
455459 }
456460
461+ #[ test]
462+ fn create_hashes_for_empty_fixed_size_lit ( ) -> Result < ( ) > {
463+ let empty_array = FixedSizeListBuilder :: new ( StringBuilder :: new ( ) , 1 ) . finish ( ) ;
464+ let random_state = RandomState :: with_seeds ( 0 , 0 , 0 , 0 ) ;
465+ let hashes_buff = & mut vec ! [ 0 ; 0 ] ;
466+ let hashes = create_hashes ( & [ Arc :: new ( empty_array) ] , & random_state, hashes_buff) ?;
467+ assert_eq ! ( hashes, & Vec :: <u64 >:: new( ) ) ;
468+ Ok ( ( ) )
469+ }
470+
457471 #[ test]
458472 fn create_hashes_for_float_arrays ( ) -> Result < ( ) > {
459473 let f32_arr = Arc :: new ( Float32Array :: from ( vec ! [ 0.12 , 0.5 , 1f32 , 444.7 ] ) ) ;
You can’t perform that action at this time.
0 commit comments