Skip to content

Commit 9faf3d4

Browse files
authored
Remove deprecated ScalarUDF::new (#12487)
It was deprecated since v 34. This also removes associated `ScalarUdfLegacyWrapper` supporting the removed function. Note that similar `SimpleScalarUDF` is retained, thus the functionality that was used to be provided by `ScalarUdfLegacyWrapper` remains available.
1 parent f86bedd commit 9faf3d4

File tree

1 file changed

+2
-81
lines changed

1 file changed

+2
-81
lines changed

datafusion/expr/src/udf.rs

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
use crate::expr::schema_name_from_exprs_comma_seperated_without_space;
2121
use crate::simplify::{ExprSimplifyResult, SimplifyInfo};
2222
use crate::sort_properties::{ExprProperties, SortProperties};
23-
use crate::{
24-
ColumnarValue, Expr, ReturnTypeFunction, ScalarFunctionImplementation, Signature,
25-
};
23+
use crate::{ColumnarValue, Expr, ScalarFunctionImplementation, Signature};
2624
use arrow::datatypes::DataType;
2725
use datafusion_common::{not_impl_err, ExprSchema, Result};
2826
use datafusion_expr_common::interval_arithmetic::Interval;
2927
use std::any::Any;
30-
use std::fmt::{self, Debug, Formatter};
28+
use std::fmt::Debug;
3129
use std::hash::{DefaultHasher, Hash, Hasher};
3230
use std::sync::Arc;
3331

@@ -73,25 +71,6 @@ impl Hash for ScalarUDF {
7371
}
7472

7573
impl ScalarUDF {
76-
/// Create a new ScalarUDF from low level details.
77-
///
78-
/// See [`ScalarUDFImpl`] for a more convenient way to create a
79-
/// `ScalarUDF` using trait objects
80-
#[deprecated(since = "34.0.0", note = "please implement ScalarUDFImpl instead")]
81-
pub fn new(
82-
name: &str,
83-
signature: &Signature,
84-
return_type: &ReturnTypeFunction,
85-
fun: &ScalarFunctionImplementation,
86-
) -> Self {
87-
Self::new_from_impl(ScalarUdfLegacyWrapper {
88-
name: name.to_owned(),
89-
signature: signature.clone(),
90-
return_type: Arc::clone(return_type),
91-
fun: Arc::clone(fun),
92-
})
93-
}
94-
9574
/// Create a new `ScalarUDF` from a `[ScalarUDFImpl]` trait object
9675
///
9776
/// Note this is the same as using the `From` impl (`ScalarUDF::from`)
@@ -719,61 +698,3 @@ impl ScalarUDFImpl for AliasedScalarUDFImpl {
719698
hasher.finish()
720699
}
721700
}
722-
723-
/// Implementation of [`ScalarUDFImpl`] that wraps the function style pointers
724-
/// of the older API (see <https://github.com/apache/datafusion/pull/8578>
725-
/// for more details)
726-
struct ScalarUdfLegacyWrapper {
727-
/// The name of the function
728-
name: String,
729-
/// The signature (the types of arguments that are supported)
730-
signature: Signature,
731-
/// Function that returns the return type given the argument types
732-
return_type: ReturnTypeFunction,
733-
/// actual implementation
734-
///
735-
/// The fn param is the wrapped function but be aware that the function will
736-
/// be passed with the slice / vec of columnar values (either scalar or array)
737-
/// with the exception of zero param function, where a singular element vec
738-
/// will be passed. In that case the single element is a null array to indicate
739-
/// the batch's row count (so that the generative zero-argument function can know
740-
/// the result array size).
741-
fun: ScalarFunctionImplementation,
742-
}
743-
744-
impl Debug for ScalarUdfLegacyWrapper {
745-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
746-
f.debug_struct("ScalarUDF")
747-
.field("name", &self.name)
748-
.field("signature", &self.signature)
749-
.field("fun", &"<FUNC>")
750-
.finish()
751-
}
752-
}
753-
754-
impl ScalarUDFImpl for ScalarUdfLegacyWrapper {
755-
fn as_any(&self) -> &dyn Any {
756-
self
757-
}
758-
fn name(&self) -> &str {
759-
&self.name
760-
}
761-
762-
fn signature(&self) -> &Signature {
763-
&self.signature
764-
}
765-
766-
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
767-
// Old API returns an Arc of the datatype for some reason
768-
let res = (self.return_type)(arg_types)?;
769-
Ok(res.as_ref().clone())
770-
}
771-
772-
fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
773-
(self.fun)(args)
774-
}
775-
776-
fn aliases(&self) -> &[String] {
777-
&[]
778-
}
779-
}

0 commit comments

Comments
 (0)