thinkharderdev commented on code in PR #8578:
URL: https://github.com/apache/arrow-datafusion/pull/8578#discussion_r1506097216


##########
datafusion/expr/src/udf.rs:
##########
@@ -17,21 +17,32 @@
 
 //! [`ScalarUDF`]: Scalar User Defined Functions
 
-use crate::{Expr, ReturnTypeFunction, ScalarFunctionImplementation, Signature};
+use crate::{
+    ColumnarValue, Expr, ReturnTypeFunction, ScalarFunctionImplementation, 
Signature,
+};
 use arrow::datatypes::DataType;
 use datafusion_common::Result;
+use std::any::Any;
 use std::fmt;
 use std::fmt::Debug;
 use std::fmt::Formatter;
 use std::sync::Arc;
 
 /// Logical representation of a Scalar User Defined Function.
 ///
-/// A scalar function produces a single row output for each row of input.
+/// A scalar function produces a single row output for each row of input. This
+/// struct contains the information DataFusion needs to plan and invoke
+/// functions you supply such name, type signature, return type, and actual
+/// implementation.
 ///
-/// This struct contains the information DataFusion needs to plan and invoke
-/// functions such name, type signature, return type, and actual 
implementation.
 ///
+/// 1. For simple (less performant) use cases, use [`create_udf`] and 
[`simple_udf.rs`].

Review Comment:
   Using `create_udf` create an extra indirection. Under the hood it's creating 
a 
   ```
   pub struct SimpleScalarUDF {
       name: String,
       signature: Signature,
       return_type: DataType,
       fun: ScalarFunctionImplementation,
   }
   
   impl ScalarUDFImpl for SimpleScalarUDF {
       fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
           (self.fun)(args)
       }
   }
   ```
   
   so it adds an extra call for every batch processed through the UDF



-- 
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]

Reply via email to