You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2024/01/31 22:50:09 UTC

Re: [PR] Add `FunctionRegistry::register_udaf` and `FunctionRegistry::register_udwf` [arrow-datafusion]

alamb commented on code in PR #9075:
URL: https://github.com/apache/arrow-datafusion/pull/9075#discussion_r1473574423


##########
datafusion/execution/src/registry.rs:
##########
@@ -45,7 +48,26 @@ pub trait FunctionRegistry {
         not_impl_err!("Registering ScalarUDF")
     }
 
-    // TODO add register_udaf and register_udwf
+    /// Registers a new [`AggregateUDF`], returning any previously registered
+    /// implementation.
+    ///
+    /// Returns an error (the default) if the function can not be registered,
+    /// for example if the registry is read only.
+    fn register_udaf(

Review Comment:
   This is the key (backwards compatible) API addition in this PR



##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -823,15 +823,7 @@ impl SessionContext {
     /// Any functions registered with the udf name or its aliases will be overwritten with this new function
     pub fn register_udf(&self, f: ScalarUDF) {
         let mut state = self.state.write();
-        let aliases = f.aliases();
-        for alias in aliases {
-            state
-                .scalar_functions
-                .insert(alias.to_string(), Arc::new(f.clone()));
-        }
-        state
-            .scalar_functions
-            .insert(f.name().to_string(), Arc::new(f));
+        state.register_udf(Arc::new(f)).ok();

Review Comment:
   moved into SessionState



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org