Apache DataFusion SQL Query Engine
Allow constructing ScalarUDF from shared implementation (#14541)
Piotr Findeisen22fb5f7aaf7b
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rsindex 84a513b21b..7ffc6623ea 100644--- a/datafusion/expr/src/udaf.rs+++ b/datafusion/expr/src/udaf.rs@@ -119,9 +119,12 @@ impl AggregateUDF {whereF: AggregateUDFImpl + 'static,{- Self {- inner: Arc::new(fun),- }+ Self::new_from_shared_impl(Arc::new(fun))+ }++ /// Create a new `AggregateUDF` from a `[AggregateUDFImpl]` trait object+ pub fn new_from_shared_impl(fun: Arc<dyn AggregateUDFImpl>) -> AggregateUDF {+ Self { inner: fun }}/// Return the underlying [`AggregateUDFImpl`] trait object for this functiondiff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rsindex aa6a5cddad..b41d975203 100644--- a/datafusion/expr/src/udf.rs+++ b/datafusion/expr/src/udf.rs@@ -91,9 +91,12 @@ impl ScalarUDF {whereF: ScalarUDFImpl + 'static,{- Self {- inner: Arc::new(fun),- }+ Self::new_from_shared_impl(Arc::new(fun))+ }++ /// Create a new `ScalarUDF` from a `[ScalarUDFImpl]` trait object+ pub fn new_from_shared_impl(fun: Arc<dyn ScalarUDFImpl>) -> ScalarUDF {+ Self { inner: fun }}/// Return the underlying [`ScalarUDFImpl`] trait object for this functiondiff --git a/datafusion/expr/src/udwf.rs b/datafusion/expr/src/udwf.rsindex 39e1e8f261..96929ffeb0 100644--- a/datafusion/expr/src/udwf.rs+++ b/datafusion/expr/src/udwf.rs@@ -100,9 +100,12 @@ impl WindowUDF {whereF: WindowUDFImpl + 'static,{- Self {- inner: Arc::new(fun),- }+ Self::new_from_shared_impl(Arc::new(fun))+ }++ /// Create a new `WindowUDF` from a `[WindowUDFImpl]` trait object+ pub fn new_from_shared_impl(fun: Arc<dyn WindowUDFImpl>) -> WindowUDF {+ Self { inner: fun }}/// Return the underlying [`WindowUDFImpl`] trait object for this function