This is an automated email from the ASF dual-hosted git repository.

jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 523a455b2a Add SimpleScalarUDF::new_with_signature (#13592)
523a455b2a is described below

commit 523a455b2aab440db7afd90ab3c5223f880ea901
Author: Piotr Findeisen <[email protected]>
AuthorDate: Sat Nov 30 01:47:39 2024 +0100

    Add SimpleScalarUDF::new_with_signature (#13592)
    
    * Add SimpleScalarUDF::new_with_signature
    
    This is helpful for simple function implementations or function stubs,
    when `Signature::exact` is not desired.
    
    * Add/update doc strings
---
 datafusion/expr/src/expr_fn.rs | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rs
index 60cd3f911e..681eb3c0af 100644
--- a/datafusion/expr/src/expr_fn.rs
+++ b/datafusion/expr/src/expr_fn.rs
@@ -434,10 +434,24 @@ impl SimpleScalarUDF {
         volatility: Volatility,
         fun: ScalarFunctionImplementation,
     ) -> Self {
-        let name = name.into();
-        let signature = Signature::exact(input_types, volatility);
-        Self {
+        Self::new_with_signature(
             name,
+            Signature::exact(input_types, volatility),
+            return_type,
+            fun,
+        )
+    }
+
+    /// Create a new `SimpleScalarUDF` from a name, signature, return type and
+    /// implementation. Implementing [`ScalarUDFImpl`] allows more flexibility
+    pub fn new_with_signature(
+        name: impl Into<String>,
+        signature: Signature,
+        return_type: DataType,
+        fun: ScalarFunctionImplementation,
+    ) -> Self {
+        Self {
+            name: name.into(),
             signature,
             return_type,
             fun,
@@ -519,7 +533,7 @@ impl Debug for SimpleAggregateUDF {
 }
 
 impl SimpleAggregateUDF {
-    /// Create a new `AggregateUDFImpl` from a name, input types, return type, 
state type and
+    /// Create a new `SimpleAggregateUDF` from a name, input types, return 
type, state type and
     /// implementation. Implementing [`AggregateUDFImpl`] allows more 
flexibility
     pub fn new(
         name: impl Into<String>,
@@ -540,6 +554,8 @@ impl SimpleAggregateUDF {
         }
     }
 
+    /// Create a new `SimpleAggregateUDF` from a name, signature, return type, 
state type and
+    /// implementation. Implementing [`AggregateUDFImpl`] allows more 
flexibility
     pub fn new_with_signature(
         name: impl Into<String>,
         signature: Signature,


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

Reply via email to