@@ -107,7 +107,13 @@ pub fn from_unary_expr(
107107 Expr :: Negative ( arg) => ( "negate" , arg) ,
108108 expr => not_impl_err ! ( "Unsupported expression: {expr:?}" ) ?,
109109 } ;
110- to_substrait_unary_scalar_fn ( producer, fn_name, arg, schema)
110+ let ( _, output_field) = expr. to_field ( schema) ?;
111+ let output_type = to_substrait_type (
112+ producer,
113+ output_field. data_type ( ) ,
114+ output_field. is_nullable ( ) ,
115+ ) ?;
116+ to_substrait_unary_scalar_fn ( producer, fn_name, arg, schema, & output_type)
111117}
112118
113119pub fn from_binary_expr (
@@ -225,6 +231,7 @@ fn to_substrait_unary_scalar_fn(
225231 fn_name : & str ,
226232 arg : & Expr ,
227233 schema : & DFSchemaRef ,
234+ output_type : & Type ,
228235) -> datafusion:: common:: Result < Expression > {
229236 let function_anchor = producer. register_function ( fn_name. to_string ( ) ) ;
230237 let substrait_expr = producer. handle_expr ( arg, schema) ?;
@@ -235,7 +242,7 @@ fn to_substrait_unary_scalar_fn(
235242 arguments : vec ! [ FunctionArgument {
236243 arg_type: Some ( ArgType :: Value ( substrait_expr) ) ,
237244 } ] ,
238- output_type : None ,
245+ output_type : Some ( output_type . clone ( ) ) ,
239246 options : vec ! [ ] ,
240247 ..Default :: default ( )
241248 } ) ) ,
0 commit comments