@@ -2,13 +2,18 @@ use std::any::Any;
22use std:: sync:: Arc ;
33
44use datafusion:: arrow:: array:: { ArrayRef , ListBuilder , StringBuilder } ;
5- use datafusion:: arrow:: datatypes:: DataType ;
5+ use datafusion:: arrow:: datatypes:: { DataType , Field } ;
66use datafusion:: common:: { Result as DataFusionResult , ScalarValue } ;
77use datafusion:: logical_expr:: { ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility } ;
88use jiter:: Peek ;
99
1010use crate :: common:: { get_err, invoke, jiter_json_find, return_type_check, GetError , InvokeResult , JsonPath } ;
1111use crate :: common_macros:: make_udf_function;
12+ use crate :: common_union:: json_field_metadata;
13+
14+ fn list_item_field ( ) -> Field {
15+ Field :: new ( "item" , DataType :: Utf8 , true ) . with_metadata ( json_field_metadata ( ) )
16+ }
1217
1318make_udf_function ! (
1419 JsonGetArray ,
@@ -46,15 +51,7 @@ impl ScalarUDFImpl for JsonGetArray {
4651 }
4752
4853 fn return_type ( & self , arg_types : & [ DataType ] ) -> DataFusionResult < DataType > {
49- return_type_check (
50- arg_types,
51- self . name ( ) ,
52- DataType :: List ( Arc :: new ( datafusion:: arrow:: datatypes:: Field :: new (
53- "item" ,
54- DataType :: Utf8 ,
55- true ,
56- ) ) ) ,
57- )
54+ return_type_check ( arg_types, self . name ( ) , DataType :: List ( Arc :: new ( list_item_field ( ) ) ) )
5855 }
5956
6057 fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> DataFusionResult < ColumnarValue > {
@@ -96,7 +93,7 @@ impl InvokeResult for BuildArrayList {
9693
9794 fn builder ( capacity : usize ) -> Self :: Builder {
9895 let values_builder = StringBuilder :: new ( ) ;
99- ListBuilder :: with_capacity ( values_builder, capacity)
96+ ListBuilder :: with_capacity ( values_builder, capacity) . with_field ( list_item_field ( ) )
10097 }
10198
10299 fn append_value ( builder : & mut Self :: Builder , value : Option < Self :: Item > ) {
@@ -108,7 +105,7 @@ impl InvokeResult for BuildArrayList {
108105 }
109106
110107 fn scalar ( value : Option < Self :: Item > ) -> ScalarValue {
111- let mut builder = ListBuilder :: new ( StringBuilder :: new ( ) ) ;
108+ let mut builder = ListBuilder :: new ( StringBuilder :: new ( ) ) . with_field ( list_item_field ( ) ) ;
112109
113110 if let Some ( array_items) = value {
114111 for item in array_items {
0 commit comments