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 e4d3f23
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,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 +459,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 e4d3f23

Please sign in to comment.