jorgecarleitao commented on a change in pull request #8032: URL: https://github.com/apache/arrow/pull/8032#discussion_r477045153
########## File path: rust/datafusion/src/logicalplan.rs ########## @@ -1042,6 +998,35 @@ pub fn can_coerce_from(type_into: &DataType, type_from: &DataType) -> bool { } } +/// A registry of functions used to plan queries programmatically Review comment: That is an excellent idea. I am trying to implement it, but I am facing a challenge; could you help me here? I've implemented the trait and moved the implementation for the `ExecutionContextState`, which is where the scalar is and what the DataFrame has access to: ``` impl UDFFactory for ExecutionContextState { fn udf(&self, name: &str, args: Vec<Expr>) -> Result<Expr> { ... } ``` On the dataframe, we will need to do something like ``` fn registry(&self) -> &dyn UDFFactory { self.ctx_state ... } ``` but `self.ctx_state` is under a mutex: `Arc<Mutex<ExecutionContextState>>`. This seems fair (safety wise): another thread could be trying to register a new UDF while we are trying to use one, in which case one of them should wait. However, I am struggling to write the interface to handle this. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org