edmondop commented on code in PR #8360:
URL: https://github.com/apache/arrow-datafusion/pull/8360#discussion_r1409598512


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -811,8 +811,14 @@ impl SessionContext {
     /// - `SELECT MY_FUNC(x)...` will look for a function named `"my_func"`
     /// - `SELECT "my_FUNC"(x)` will look for a function named `"my_FUNC"`
     pub fn register_udf(&self, f: ScalarUDF) {
-        self.state
-            .write()
+        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()));

Review Comment:
   How do we want to handle the fact that another function could be registered 
with the same alias?  I know this function doesn't return an error, but I 
suspect that overwriting the alias is not the expected behavior



##########
datafusion/core/tests/user_defined/user_defined_scalar_functions.rs:
##########
@@ -341,6 +341,43 @@ async fn 
case_sensitive_identifiers_user_defined_functions() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn test_user_defined_functions_with_alias() -> Result<()> {

Review Comment:
   Maybe useful to test again the case where you create a udf1 with an alias 
and then a different udf with the same alias? I don't know what's the expected 
behavior there



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