11use crate :: common:: { invoke, parse_jsonpath, return_type_check} ;
22use crate :: common_macros:: make_udf_function;
3- use crate :: json_get_json:: jiter_json_get_json;
4- use datafusion:: arrow:: array:: StringArray ;
53use datafusion:: arrow:: datatypes:: { DataType , DataType :: Utf8 } ;
64use datafusion:: common:: { exec_err, Result as DataFusionResult , ScalarValue } ;
75use datafusion:: logical_expr:: { ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility } ;
86use std:: any:: Any ;
7+ use crate :: common_union:: JsonUnion ;
8+ use crate :: json_get:: jiter_json_get_union;
99
1010make_udf_function ! (
1111 JsonExtract ,
@@ -46,7 +46,7 @@ impl ScalarUDFImpl for JsonExtract {
4646 }
4747
4848 fn return_type ( & self , arg_types : & [ DataType ] ) -> DataFusionResult < DataType > {
49- return_type_check ( arg_types, self . name ( ) , Utf8 )
49+ return_type_check ( arg_types, self . name ( ) , JsonUnion :: data_type ( ) )
5050 }
5151
5252 fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> DataFusionResult < ColumnarValue > {
@@ -73,7 +73,9 @@ impl ScalarUDFImpl for JsonExtract {
7373
7474 let path = parse_jsonpath ( path_str) ;
7575
76- invoke :: < StringArray > ( & [ json_arg. clone ( ) ] , |json, _| jiter_json_get_json ( json, & path) )
76+ invoke :: < JsonUnion > ( & [ json_arg. clone ( ) ] , |json, _| {
77+ jiter_json_get_union ( json, & path)
78+ } )
7779 }
7880
7981 fn aliases ( & self ) -> & [ String ] {
0 commit comments