milenkovicm commented on code in PR #9333:
URL: https://github.com/apache/arrow-datafusion/pull/9333#discussion_r1507799073


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -1246,7 +1273,42 @@ impl QueryPlanner for DefaultQueryPlanner {
             .await
     }
 }
+/// Crates and registers a function from [CreateFunction] statement
+///
+/// It is intended to handle `CREATE FUNCTION` statements
+/// and interact with [SessionState] to registers new udfs.
+///
+/// Datafusion `SQL` dialect does not support `CREATE FUNCTION`
+/// in generic dialect, so dialect should be changed to `PostgreSQL`
+///
+/// ```rust, no_run
+/// # use datafusion::execution::config::SessionConfig;
+/// SessionConfig::new().set_str("datafusion.sql_parser.dialect", 
"PostgreSQL");
+/// ```
+#[async_trait]
+pub trait FunctionFactory: Sync + Send {
+    // TODO: I don't like having RwLock Leaking here, who ever implements it
+    //       has to depend ot `parking_lot`. I'f we expose &mut SessionState it
+    //       may keep lock of too long.
+    //
+    //       Not sure if there is better approach.
+    //
+
+    /// Handles creation of user defined function specified in 
[CreateFunction] statement
+    async fn create(
+        &self,
+        state: Arc<RwLock<SessionState>>,

Review Comment:
   I definitely like this approach, but it has lock problem if we want to 
provide a `config` parameter. 
   
   Why would we need `config`? `FunctionFactory` may store configuration for 
model repository url, or similar 



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