alamb opened a new issue, #9178:
URL: https://github.com/apache/arrow-datafusion/issues/9178

   ### Is your feature request related to a problem or challenge?
   
   Asked on discord: 
https://discord.com/channels/885562378132000778/1166447479609376850/1205283780378755156
   
   > Is it possible to deregister a UDF from a SessionContext? I would like to 
remove all ScalarUDFs with a specific function name from my context, but 
there's no deregister function.
   
   There are functions to add udf/udaf/udwf to SessionContext but not to remove 
them
   
   
https://github.com/apache/arrow-datafusion/blob/c9e4b7b7c5c2c2e7b3ea01040a6edeafd151410c/datafusion/core/src/execution/context/mod.rs#L816-L827
   
   It is possible to remove tables with `SessionContext::deregister_table`:
   
https://github.com/apache/arrow-datafusion/blob/c9e4b7b7c5c2c2e7b3ea01040a6edeafd151410c/datafusion/core/src/execution/context/mod.rs#L1039-L1049
   
   ### Describe the solution you'd like
   
   Add the corresponding deregister functions to SessionContext
   
   ```rust
   impl SessionContext {
   ...
       /// returns the previously registered table/scalar/etc function, if any
       pub fn deregister_udtf(&self, name: &str) -> ,Result<Option<Arc<dyn 
TableFunctionImpl>)  { ... }
       pub fn deregister_udf(&self) ->  Result<Option<Arc<ScalarUDF>>> {...}
       pub fn deregister_udaf(&self) -> Result<Option<Arc<AggregateUDF>>> {...}
       pub fn deregister_udwf(&self) -> Result<Options<Arc<WindowUDF>>> { ... }
   ...
   ```
   
   
   Ideally, we should also  add the corresponding methods to `FunctionRegistry` 
and `SessionState`:
   
   ```rust
   impl FunctionRegistry {
   ...
       /// returns the previously registered table/scalar/etc function, if any
       /// defaults to "not yet implemented"
       pub fn deregister_udf(&self) ->  Result<Option<Arc<ScalarUDF>>> {...}
       pub fn deregister_udaf(&self) -> Result<Option<Arc<AggregateUDF>>> {...}
       pub fn deregister_udwf(&self) -> Result<Options<Arc<WindowUDF>>> { ... }
   ...
   ```
   
   
   ```rust
   impl FunctionRegistry for SessionState  {
   ...
       pub fn deregister_udf(&self) ->  Result<Option<Arc<ScalarUDF>>> {...}
       pub fn deregister_udaf(&self) -> Result<Option<Arc<AggregateUDF>>> {...}
       pub fn deregister_udwf(&self) -> Result<Options<Arc<WindowUDF>>> { ... }
   ...
   ```
   
   So the task is to
   1.  add the above functions
   2.  add basic tests (can adapt existing tests that register functions) that 
show after `deregister_XXX` the function can not be called anymore
   
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   I think this would be a great first project as it:
   1. Is well defined
   2. Would make a real impact and expose you to the code / tests
   3. Would contribute to the overall improvements we are making to the user 
defined functiosn 


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