Skip to content

Commit

Permalink
Remove deprecated WindowUDF::new
Browse files Browse the repository at this point in the history
Deprecated since v 34. Remove it along with associated
`WindowUDFLegacyWrapper`.
  • Loading branch information
findepi committed Sep 17, 2024
1 parent a08f923 commit 2d623b4
Showing 1 changed file with 1 addition and 70 deletions.
71 changes: 1 addition & 70 deletions datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ use datafusion_common::{not_impl_err, Result};

use crate::expr::WindowFunction;
use crate::{
function::WindowFunctionSimplification, Expr, PartitionEvaluator,
PartitionEvaluatorFactory, ReturnTypeFunction, Signature,
function::WindowFunctionSimplification, Expr, PartitionEvaluator, Signature,
};

/// Logical representation of a user-defined window function (UDWF)
Expand Down Expand Up @@ -81,25 +80,6 @@ impl Hash for WindowUDF {
}

impl WindowUDF {
/// Create a new WindowUDF from low level details.
///
/// See [`WindowUDFImpl`] for a more convenient way to create a
/// `WindowUDF` using trait objects
#[deprecated(since = "34.0.0", note = "please implement WindowUDFImpl instead")]
pub fn new(
name: &str,
signature: &Signature,
return_type: &ReturnTypeFunction,
partition_evaluator_factory: &PartitionEvaluatorFactory,
) -> Self {
Self::new_from_impl(WindowUDFLegacyWrapper {
name: name.to_owned(),
signature: signature.clone(),
return_type: Arc::clone(return_type),
partition_evaluator_factory: Arc::clone(partition_evaluator_factory),
})
}

/// Create a new `WindowUDF` from a `[WindowUDFImpl]` trait object
///
/// Note this is the same as using the `From` impl (`WindowUDF::from`)
Expand Down Expand Up @@ -478,55 +458,6 @@ impl WindowUDFImpl for AliasedWindowUDFImpl {
}
}

/// Implementation of [`WindowUDFImpl`] that wraps the function style pointers
/// of the older API (see <https://github.com/apache/datafusion/pull/8719>
/// for more details)
pub struct WindowUDFLegacyWrapper {
/// name
name: String,
/// signature
signature: Signature,
/// Return type
return_type: ReturnTypeFunction,
/// Return the partition evaluator
partition_evaluator_factory: PartitionEvaluatorFactory,
}

impl Debug for WindowUDFLegacyWrapper {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("WindowUDF")
.field("name", &self.name)
.field("signature", &self.signature)
.field("return_type", &"<func>")
.field("partition_evaluator_factory", &"<func>")
.finish_non_exhaustive()
}
}

impl WindowUDFImpl for WindowUDFLegacyWrapper {
fn as_any(&self) -> &dyn Any {
self
}

fn name(&self) -> &str {
&self.name
}

fn signature(&self) -> &Signature {
&self.signature
}

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
// Old API returns an Arc of the datatype for some reason
let res = (self.return_type)(arg_types)?;
Ok(res.as_ref().clone())
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
(self.partition_evaluator_factory)()
}
}

#[cfg(test)]
mod test {
use crate::{PartitionEvaluator, WindowUDF, WindowUDFImpl};
Expand Down

0 comments on commit 2d623b4

Please sign in to comment.