@@ -28,7 +28,7 @@ use arrow::array::{
2828use arrow:: compute:: kernels:: numeric:: add;
2929use arrow:: datatypes:: { DataType , Field , Schema } ;
3030use arrow_schema:: extension:: { Bool8 , CanonicalExtensionType , ExtensionType } ;
31- use arrow_schema:: ArrowError ;
31+ use arrow_schema:: { ArrowError , FieldRef } ;
3232use datafusion:: common:: test_util:: batches_to_string;
3333use datafusion:: execution:: context:: { FunctionFactory , RegisterFunction , SessionState } ;
3434use datafusion:: prelude:: * ;
@@ -814,7 +814,7 @@ impl ScalarUDFImpl for TakeUDF {
814814 ///
815815 /// 1. If the third argument is '0', return the type of the first argument
816816 /// 2. If the third argument is '1', return the type of the second argument
817- fn return_field_from_args ( & self , args : ReturnFieldArgs ) -> Result < Field > {
817+ fn return_field_from_args ( & self , args : ReturnFieldArgs ) -> Result < FieldRef > {
818818 if args. arg_fields . len ( ) != 3 {
819819 return plan_err ! ( "Expected 3 arguments, got {}." , args. arg_fields. len( ) ) ;
820820 }
@@ -845,7 +845,8 @@ impl ScalarUDFImpl for TakeUDF {
845845 self . name ( ) ,
846846 args. arg_fields [ take_idx] . data_type ( ) . to_owned ( ) ,
847847 true ,
848- ) )
848+ )
849+ . into ( ) )
849850 }
850851
851852 // The actual implementation
@@ -1412,9 +1413,10 @@ impl ScalarUDFImpl for MetadataBasedUdf {
14121413 ) ;
14131414 }
14141415
1415- fn return_field_from_args ( & self , _args : ReturnFieldArgs ) -> Result < Field > {
1416+ fn return_field_from_args ( & self , _args : ReturnFieldArgs ) -> Result < FieldRef > {
14161417 Ok ( Field :: new ( self . name ( ) , DataType :: UInt64 , true )
1417- . with_metadata ( self . metadata . clone ( ) ) )
1418+ . with_metadata ( self . metadata . clone ( ) )
1419+ . into ( ) )
14181420 }
14191421
14201422 fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> Result < ColumnarValue > {
@@ -1562,14 +1564,15 @@ impl ScalarUDFImpl for ExtensionBasedUdf {
15621564 Ok ( DataType :: Utf8 )
15631565 }
15641566
1565- fn return_field_from_args ( & self , _args : ReturnFieldArgs ) -> Result < Field > {
1567+ fn return_field_from_args ( & self , _args : ReturnFieldArgs ) -> Result < FieldRef > {
15661568 Ok ( Field :: new ( "canonical_extension_udf" , DataType :: Utf8 , true )
1567- . with_extension_type ( MyUserExtentionType { } ) )
1569+ . with_extension_type ( MyUserExtentionType { } )
1570+ . into ( ) )
15681571 }
15691572
15701573 fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> Result < ColumnarValue > {
15711574 assert_eq ! ( args. arg_fields. len( ) , 1 ) ;
1572- let input_field = args. arg_fields [ 0 ] ;
1575+ let input_field = args. arg_fields [ 0 ] . as_ref ( ) ;
15731576
15741577 let output_as_bool = matches ! (
15751578 CanonicalExtensionType :: try_from( input_field) ,
0 commit comments