milenkovicm commented on code in PR #9333:
URL: https://github.com/apache/arrow-datafusion/pull/9333#discussion_r1506768428
##########
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:
Should we want to implement sql user defined functions, we would need
extension to cache logical expressions and provide them to logical analyser so
it can replace udf call with the expression.
Id argue we need state or configuration as a parameter as well. Let me do
other changes, as they are straightforward and we can try to find most
ergonomic function
--
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]