diff --git a/datafusion/core/tests/user_defined/user_defined_aggregates.rs b/datafusion/core/tests/user_defined/user_defined_aggregates.rs index db70caf52534..982b4804597e 100644 --- a/datafusion/core/tests/user_defined/user_defined_aggregates.rs +++ b/datafusion/core/tests/user_defined/user_defined_aggregates.rs @@ -53,6 +53,7 @@ use datafusion::{ }; use datafusion_common::{assert_contains, exec_datafusion_err}; use datafusion_common::{cast::as_primitive_array, exec_err}; + use datafusion_expr::expr::WindowFunction; use datafusion_expr::{ col, create_udaf, function::AccumulatorArgs, AggregateUDFImpl, Expr, @@ -297,10 +298,12 @@ async fn deregister_udaf() -> Result<()> { ctx.register_udaf(my_avg); assert!(ctx.state().aggregate_functions().contains_key("my_avg")); + assert!(datafusion_execution::FunctionRegistry::udafs(&ctx).contains("my_avg")); ctx.deregister_udaf("my_avg"); assert!(!ctx.state().aggregate_functions().contains_key("my_avg")); + assert!(!datafusion_execution::FunctionRegistry::udafs(&ctx).contains("my_avg")); Ok(()) } diff --git a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs index 1c155853b21c..b0d0c94c1737 100644 --- a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs @@ -775,10 +775,12 @@ async fn deregister_udf() -> Result<()> { ctx.register_udf(cast2i64); assert!(ctx.udfs().contains("cast_to_i64")); + assert!(FunctionRegistry::udfs(&ctx).contains("cast_to_i64")); ctx.deregister_udf("cast_to_i64"); assert!(!ctx.udfs().contains("cast_to_i64")); + assert!(!FunctionRegistry::udfs(&ctx).contains("cast_to_i64")); Ok(()) } diff --git a/datafusion/core/tests/user_defined/user_defined_window_functions.rs b/datafusion/core/tests/user_defined/user_defined_window_functions.rs index 555b57fbe62d..8871e3af275f 100644 --- a/datafusion/core/tests/user_defined/user_defined_window_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_window_functions.rs @@ -128,10 +128,12 @@ async fn test_deregister_udwf() -> Result<()> { OddCounter::register(&mut ctx, Arc::clone(&test_state)); assert!(ctx.state().window_functions().contains_key("odd_counter")); + assert!(datafusion_execution::FunctionRegistry::udwfs(&ctx).contains("odd_counter")); ctx.deregister_udwf("odd_counter"); assert!(!ctx.state().window_functions().contains_key("odd_counter")); + assert!(!datafusion_execution::FunctionRegistry::udwfs(&ctx).contains("odd_counter")); Ok(()) } diff --git a/datafusion/expr/src/registry.rs b/datafusion/expr/src/registry.rs index 8ea9e34dac12..9554dd68e175 100644 --- a/datafusion/expr/src/registry.rs +++ b/datafusion/expr/src/registry.rs @@ -31,20 +31,10 @@ pub trait FunctionRegistry { fn udfs(&self) -> HashSet; /// Returns names of all available aggregate user defined functions. - fn udafs(&self) -> HashSet { - // This default implementation is provided temporarily - // to maintain backward compatibility for the 50.1 release. - // It will be reverted to a required method in future versions. - HashSet::default() - } + fn udafs(&self) -> HashSet; /// Returns names of all available window user defined functions. - fn udwfs(&self) -> HashSet { - // This default implementation is provided temporarily - // to maintain backward compatibility for the 50.1 release. - // It will be reverted to a required method in future versions. - HashSet::default() - } + fn udwfs(&self) -> HashSet; /// Returns a reference to the user defined scalar function (udf) named /// `name`. diff --git a/docs/source/library-user-guide/upgrading.md b/docs/source/library-user-guide/upgrading.md index d70413467a95..e93659872565 100644 --- a/docs/source/library-user-guide/upgrading.md +++ b/docs/source/library-user-guide/upgrading.md @@ -31,6 +31,25 @@ The Minimum Supported Rust Version (MSRV) has been updated to [`1.87.0`]. [`1.87.0`]: https://releases.rs/docs/1.87.0/ +### `FunctionRegistry` exposes two additional methods + +`FunctionRegistry` exposes two additional methods `udafs` and `udwfs` which expose set of registered user defined aggregation and window function names. To upgrade implement methods returning set of registered function names: + +```diff +impl FunctionRegistry for FunctionRegistryImpl { + fn udfs(&self) -> HashSet { + self.scalar_functions.keys().cloned().collect() + } ++ fn udafs(&self) -> HashSet { ++ self.aggregate_functions.keys().cloned().collect() ++ } ++ ++ fn udwfs(&self) -> HashSet { ++ self.window_functions.keys().cloned().collect() ++ } +} +``` + ### `datafusion-proto` use `TaskContext` rather than `SessionContext` in physical plan serde methods There have been changes in the public API methods of `datafusion-proto` which handle physical plan serde.