Skip to content

Commit

Permalink
Remove WindowUDFImpl::return_type
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsherin committed Sep 17, 2024
1 parent 25b299e commit ce7df3a
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 69 deletions.
5 changes: 0 additions & 5 deletions datafusion-examples/examples/advanced_udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ impl WindowUDFImpl for SmoothItUdf {
&self.signature
}

/// What is the type of value that will be returned by this function.
fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(DataType::Float64)
}

/// Create a `PartitionEvaluator` to evaluate this function on a new
/// partition.
fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
Expand Down
4 changes: 0 additions & 4 deletions datafusion-examples/examples/simplify_udwf_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ impl WindowUDFImpl for SimplifySmoothItUdf {
&self.signature
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(DataType::Float64)
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
todo!()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,6 @@ impl OddCounter {
&self.signature
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(DataType::Int64)
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
Ok(Box::new(OddCounter::new(Arc::clone(&self.test_state))))
}
Expand Down
4 changes: 0 additions & 4 deletions datafusion/expr/src/expr_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,6 @@ impl WindowUDFImpl for SimpleWindowUDF {
&self.signature
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(self.return_type.clone())
}

fn partition_evaluator(&self) -> Result<Box<dyn crate::PartitionEvaluator>> {
(self.partition_evaluator_factory)()
}
Expand Down
33 changes: 0 additions & 33 deletions datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,6 @@ impl WindowUDF {
self.inner.signature()
}

/// Return the type of the function given its input types
///
/// See [`WindowUDFImpl::return_type`] for more details.
#[allow(deprecated)]
pub fn return_type(&self, args: &[DataType]) -> Result<DataType> {
self.inner.return_type(args)
}

/// Do the function rewrite
///
/// See [`WindowUDFImpl::simplify`] for more details.
Expand Down Expand Up @@ -284,14 +276,6 @@ pub trait WindowUDFImpl: Debug + Send + Sync {
/// types are accepted and the function's Volatility.
fn signature(&self) -> &Signature;

/// What [`DataType`] will be returned by this function, given the types of
/// the arguments
#[deprecated(
since = "41.0.0",
note = "Use `field` instead to define the final result of evaluating this user-defined window function."
)]
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType>;

/// Invoke the function, returning the [`PartitionEvaluator`] instance
fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>>;

Expand Down Expand Up @@ -437,11 +421,6 @@ impl WindowUDFImpl for AliasedWindowUDFImpl {
self.inner.signature()
}

#[allow(deprecated)]
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
self.inner.return_type(arg_types)
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
self.inner.partition_evaluator()
}
Expand Down Expand Up @@ -520,12 +499,6 @@ impl WindowUDFImpl for WindowUDFLegacyWrapper {
&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)()
}
Expand Down Expand Up @@ -579,9 +552,6 @@ mod test {
fn signature(&self) -> &Signature {
&self.signature
}
fn return_type(&self, _args: &[DataType]) -> Result<DataType> {
unimplemented!()
}
fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
unimplemented!()
}
Expand Down Expand Up @@ -618,9 +588,6 @@ mod test {
fn signature(&self) -> &Signature {
&self.signature
}
fn return_type(&self, _args: &[DataType]) -> Result<DataType> {
unimplemented!()
}
fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
unimplemented!()
}
Expand Down
4 changes: 0 additions & 4 deletions datafusion/functions-window/src/row_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ impl WindowUDFImpl for RowNumber {
&self.signature
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(DataType::UInt64)
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
Ok(Box::<NumRowsEvaluator>::default())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3902,10 +3902,6 @@ mod tests {
unimplemented!()
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
unimplemented!("not needed for tests")
}

fn simplify(&self) -> Option<WindowFunctionSimplification> {
if self.simplify {
Some(Box::new(|_, _| Ok(col("result_column"))))
Expand Down
11 changes: 0 additions & 11 deletions datafusion/proto/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2431,17 +2431,6 @@ fn roundtrip_window() {
&self.signature
}

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
if arg_types.len() != 1 {
return plan_err!(
"dummy_udwf expects 1 argument, got {}: {:?}",
arg_types.len(),
arg_types
);
}
Ok(arg_types[0].clone())
}

fn partition_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>> {
make_partition_evaluator()
}
Expand Down

0 comments on commit ce7df3a

Please sign in to comment.