@@ -84,11 +84,7 @@ use datafusion::physical_expr::window::WindowExpr;
84
84
use datafusion:: physical_expr:: LexOrdering ;
85
85
86
86
use crate :: parquet:: parquet_exec:: init_datasource_exec;
87
- use arrow:: array:: {
88
- Array , ArrayRef , BinaryBuilder , BooleanArray , Date32Array , Decimal128Array , Float32Array ,
89
- Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , ListArray , NullArray ,
90
- StringBuilder , TimestampMicrosecondArray ,
91
- } ;
87
+ use arrow:: array:: { new_empty_array, Array , ArrayRef , BinaryBuilder , BooleanArray , Date32Array , Decimal128Array , Float32Array , Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , ListArray , NullArray , StringBuilder , TimestampMicrosecondArray } ;
92
88
use arrow:: buffer:: { BooleanBuffer , NullBuffer , OffsetBuffer } ;
93
89
use datafusion:: common:: utils:: SingleRowListArrayBuilder ;
94
90
use datafusion:: physical_plan:: coalesce_batches:: CoalesceBatchesExec ;
@@ -2815,7 +2811,7 @@ fn literal_to_array_ref(
2815
2811
DataType :: List ( f) if !matches ! ( f. data_type( ) , DataType :: List ( _) ) => {
2816
2812
literal_to_array_ref ( f. data_type ( ) . clone ( ) , list_literal)
2817
2813
}
2818
- DataType :: List ( f) => {
2814
+ DataType :: List ( ref f) => {
2819
2815
let dt = f. data_type ( ) . clone ( ) ;
2820
2816
let child_arrays: Vec < ArrayRef > = list_literal
2821
2817
. list_values
@@ -2838,14 +2834,21 @@ fn literal_to_array_ref(
2838
2834
2839
2835
// Concatenate all child arrays' *values* into one array
2840
2836
// Example: [[1,2,3], [4,5,6]] → values = [1,2,3,4,5,6]
2841
- let concat = arrow:: compute:: concat ( & child_refs) ?;
2837
+ let output_array = if !child_refs. is_empty ( ) {
2838
+ arrow:: compute:: concat ( & child_refs) ?
2839
+ } else {
2840
+ let x = new_empty_array ( & dt. clone ( ) ) ;
2841
+ offsets = vec ! [ x. offset( ) as i32 ] ;
2842
+ dbg ! ( & offsets) ;
2843
+ x
2844
+ } ;
2842
2845
2843
2846
// Create and return the parent ListArray
2844
2847
Ok ( Arc :: new ( ListArray :: new (
2845
2848
// Field: item type matches the concatenated child's type
2846
- FieldRef :: from ( Field :: new ( "item" , concat . data_type ( ) . clone ( ) , true ) ) ,
2849
+ FieldRef :: from ( Field :: new ( "item" , output_array . data_type ( ) . clone ( ) , true ) ) ,
2847
2850
OffsetBuffer :: new ( offsets. into ( ) ) ,
2848
- concat ,
2851
+ output_array ,
2849
2852
Some ( NullBuffer :: from ( list_literal. null_mask ) ) ,
2850
2853
) ) )
2851
2854
}
@@ -3743,26 +3746,26 @@ mod tests {
3743
3746
true , // outer list nullable
3744
3747
) ) ) ;
3745
3748
3746
- let data = ListLiteral {
3747
- list_values : vec ! [
3748
- ListLiteral {
3749
- int_values: vec![ 1 , 2 ] ,
3750
- null_mask: vec![ true , true ] ,
3751
- ..Default :: default ( )
3752
- } ,
3753
- ListLiteral {
3754
- ..Default :: default ( )
3755
- }
3756
- ] ,
3757
- null_mask : vec ! [ true , false ] ,
3758
- ..Default :: default ( )
3759
- } ;
3760
-
3761
- let nested_type = DataType :: List ( FieldRef :: from ( Field :: new (
3762
- "item" ,
3763
- DataType :: List (
3764
- Field :: new ( "item" , DataType :: Int32 , true ) . into ( ) ,
3765
- ) , true ) ) ) ;
3749
+ // let data = ListLiteral {
3750
+ // list_values: vec![
3751
+ // ListLiteral {
3752
+ // int_values: vec![1, 2],
3753
+ // null_mask: vec![true, true],
3754
+ // ..Default::default()
3755
+ // },
3756
+ // ListLiteral {
3757
+ // ..Default::default()
3758
+ // }
3759
+ // ],
3760
+ // null_mask: vec![true, false],
3761
+ // ..Default::default()
3762
+ // };
3763
+ //
3764
+ // let nested_type = DataType::List(FieldRef::from(Field::new(
3765
+ // "item",
3766
+ // DataType::List(
3767
+ // Field::new("item", DataType::Int32, true).into(),
3768
+ // ), true)));
3766
3769
3767
3770
let array = literal_to_array_ref ( nested_type, data) ?;
3768
3771
0 commit comments