Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions datafusion/core/tests/user_defined/user_defined_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
14 changes: 2 additions & 12 deletions datafusion/expr/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,10 @@ pub trait FunctionRegistry {
fn udfs(&self) -> HashSet<String>;

/// Returns names of all available aggregate user defined functions.
fn udafs(&self) -> HashSet<String> {
// 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<String>;

/// Returns names of all available window user defined functions.
fn udwfs(&self) -> HashSet<String> {
// 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<String>;

/// Returns a reference to the user defined scalar function (udf) named
/// `name`.
Expand Down
19 changes: 19 additions & 0 deletions docs/source/library-user-guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


```diff
impl FunctionRegistry for FunctionRegistryImpl {
fn udfs(&self) -> HashSet<String> {
self.scalar_functions.keys().cloned().collect()
}
+ fn udafs(&self) -> HashSet<String> {
+ self.aggregate_functions.keys().cloned().collect()
+ }
+
+ fn udwfs(&self) -> HashSet<String> {
+ 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.
Expand Down