File tree 1 file changed +11
-1
lines changed
datafusion/common/src/scalar 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2207,7 +2207,11 @@ impl ScalarValue {
2207
2207
2208
2208
fn list_to_array_of_size ( arr : & dyn Array , size : usize ) -> Result < ArrayRef > {
2209
2209
let arrays = std:: iter:: repeat ( arr) . take ( size) . collect :: < Vec < _ > > ( ) ;
2210
- Ok ( arrow:: compute:: concat ( arrays. as_slice ( ) ) ?)
2210
+ let ret = match !arrays. is_empty ( ) {
2211
+ true => arrow:: compute:: concat ( arrays. as_slice ( ) ) ?,
2212
+ false => arr. slice ( 0 , 0 ) ,
2213
+ } ;
2214
+ Ok ( ret)
2211
2215
}
2212
2216
2213
2217
/// Retrieve ScalarValue for each row in `array`
@@ -3560,6 +3564,12 @@ mod tests {
3560
3564
& expected_arr,
3561
3565
as_fixed_size_list_array( actual_arr. as_ref( ) ) . unwrap( )
3562
3566
) ;
3567
+
3568
+ let empty_array = sv
3569
+ . to_array_of_size ( 0 )
3570
+ . expect ( "Failed to convert to empty array" ) ;
3571
+
3572
+ assert_eq ! ( empty_array. len( ) , 0 ) ;
3563
3573
}
3564
3574
3565
3575
#[ test]
You can’t perform that action at this time.
0 commit comments