jonahgao commented on code in PR #12922:
URL: https://github.com/apache/datafusion/pull/12922#discussion_r1801221800


##########
datafusion/functions/src/macros.rs:
##########
@@ -226,9 +226,8 @@ macro_rules! make_math_unary_udf {
                     $EVALUATE_BOUNDS(inputs)
                 }
 
-                fn invoke(&self, args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
-                    let args = ColumnarValue::values_to_arrays(args)?;
-
+                fn invoke(&self, col_args: &[ColumnarValue]) -> 
Result<ColumnarValue> {

Review Comment:
   If a function needs to maintain scalar, we can call 
`ColumnarValue::from_args_and_result` after invoking it. 
   ```rust
           // in file: datafusion/physical-expr/src/scalar_function.rs
           // evaluate the function
           let output = match self.args.is_empty() {
               true => self.fun.invoke_no_args(batch.num_rows()),
               false => self.fun.invoke(&inputs),
           }?;
   
           if let ColumnarValue::Array(array) = &output {
               if self.fun.need_maintain_scalar() && !inputs.is_empty() {
                   output = ColumnarValue::from_args_and_result(inputs, array)
               }
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to