Apache DataFusion SQL Query Engine
fix: preserve list element field in array_repeat (#25953)
Stefan Wange1fb216a10cd
diff --git a/datafusion/functions-nested/src/repeat.rs b/datafusion/functions-nested/src/repeat.rsindex dc99d78036..832b39b7ff 100644--- a/datafusion/functions-nested/src/repeat.rs+++ b/datafusion/functions-nested/src/repeat.rs@@ -298,7 +298,7 @@ fn general_list_repeat<O: OffsetSizeTrait>(None,)?;let inner_list = GenericListArray::<O>::try_new(- Arc::new(Field::new_list_field(list_array.value_type().clone(), true)),+ Arc::clone(list_array.value_field()),OffsetBuffer::new(inner_offsets.into()),inner_values,Some(NullBuffer::new(inner_nulls.finish())),diff --git a/datafusion/sqllogictest/test_files/array/array_repeat.slt b/datafusion/sqllogictest/test_files/array/array_repeat.sltindex 97e55e7718..0272c305ba 100644--- a/datafusion/sqllogictest/test_files/array/array_repeat.slt+++ b/datafusion/sqllogictest/test_files/array/array_repeat.slt@@ -271,4 +271,35 @@ statement okdrop table array_repeat_null_slot_table+# array_repeat keeps a non-nullable or custom-named element field+statement ok+create table array_repeat_field_table as select+ arrow_cast(make_array(1, 2), 'List(non-null Int64)') as non_null_list,+ arrow_cast(make_array(1, 2), 'List(Int64, field: ''element'')') as named_list,+ arrow_cast(make_array(1, 2), 'LargeList(non-null Int64)') as non_null_large_list,+ arrow_cast(make_array(1, 2), 'LargeList(Int64, field: ''element'')') as named_large_list;++query ????+select+ array_repeat(non_null_list, 2),+ array_repeat(named_list, 2),+ array_repeat(non_null_large_list, 2),+ array_repeat(named_large_list, 2)+from array_repeat_field_table;+----+[[1, 2], [1, 2]] [[1, 2], [1, 2]] [[1, 2], [1, 2]] [[1, 2], [1, 2]]++query TTTT+select+ arrow_typeof(array_repeat(non_null_list, 2)),+ arrow_typeof(array_repeat(named_list, 2)),+ arrow_typeof(array_repeat(non_null_large_list, 2)),+ arrow_typeof(array_repeat(named_large_list, 2))+from array_repeat_field_table;+----+List(List(non-null Int64)) List(List(Int64, field: 'element')) LargeList(LargeList(non-null Int64)) LargeList(LargeList(Int64, field: 'element'))++statement ok+drop table array_repeat_field_table+include ./cleanup.slt.part