@@ -78,7 +78,7 @@ use datafusion::common::{
7878use datafusion:: datasource:: listing:: PartitionedFile ;
7979use datafusion:: logical_expr:: type_coercion:: other:: get_coerce_type_for_case_expression;
8080use datafusion:: logical_expr:: {
81- AggregateUDF , ReturnTypeArgs , WindowFrame , WindowFrameBound , WindowFrameUnits ,
81+ AggregateUDF , ReturnFieldArgs , WindowFrame , WindowFrameBound , WindowFrameUnits ,
8282 WindowFunctionDefinition ,
8383} ;
8484use datafusion:: physical_expr:: expressions:: { Literal , StatsType } ;
@@ -886,7 +886,7 @@ impl PhysicalPlanner {
886886 func_name,
887887 fun_expr,
888888 vec ! [ left, right] ,
889- data_type,
889+ Field :: new ( func_name , data_type, true ) ,
890890 ) ) )
891891 }
892892 _ => Ok ( Arc :: new ( BinaryExpr :: new ( left, op, right) ) ) ,
@@ -2191,6 +2191,12 @@ impl PhysicalPlanner {
21912191 . coerce_types ( & input_expr_types)
21922192 . unwrap_or_else ( |_| input_expr_types. clone ( ) ) ;
21932193
2194+ let arg_fields = coerced_types
2195+ . iter ( )
2196+ . enumerate ( )
2197+ . map ( |( i, dt) | Field :: new ( format ! ( "arg{i}" ) , dt. clone ( ) , true ) )
2198+ . collect :: < Vec < _ > > ( ) ;
2199+
21942200 // TODO this should try and find scalar
21952201 let arguments = args
21962202 . iter ( )
@@ -2202,18 +2208,16 @@ impl PhysicalPlanner {
22022208 } )
22032209 . collect :: < Vec < _ > > ( ) ;
22042210
2205- let nullables = arguments. iter ( ) . map ( |_| true ) . collect :: < Vec < _ > > ( ) ;
2206-
2207- let args = ReturnTypeArgs {
2208- arg_types : & coerced_types,
2211+ let args = ReturnFieldArgs {
2212+ arg_fields : & arg_fields,
22092213 scalar_arguments : & arguments,
2210- nullables : & nullables,
22112214 } ;
22122215
22132216 let data_type = func
22142217 . inner ( )
2215- . return_type_from_args ( args) ?
2216- . return_type ( )
2218+ . return_field_from_args ( args) ?
2219+ . clone ( )
2220+ . data_type ( )
22172221 . clone ( ) ;
22182222
22192223 ( data_type, coerced_types)
@@ -2246,7 +2250,7 @@ impl PhysicalPlanner {
22462250 fun_name,
22472251 fun_expr,
22482252 args. to_vec ( ) ,
2249- data_type,
2253+ Field :: new ( fun_name , data_type, true ) ,
22502254 ) ) ;
22512255
22522256 Ok ( scalar_expr)
0 commit comments