Skip to content

Commit

Permalink
Deprecate ScalarUDFImpl::return_type and revert a breaking API change
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Dec 10, 2024
1 parent becd0c9 commit e17342c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions datafusion/expr/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl ScalarUDF {
///
/// See [`ScalarUDFImpl::return_type`] for more details.
pub fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
#[allow(deprecated)]
self.inner.return_type(arg_types)
}

Expand Down Expand Up @@ -450,6 +451,7 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
/// is recommended to return [`DataFusionError::Internal`].
///
/// [`DataFusionError::Internal`]: datafusion_common::DataFusionError::Internal
#[deprecated(since = "44.0.0", note = "Use `return_type_from_exprs` instead")]
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType>;

/// What [`DataType`] will be returned by this function, given the
Expand Down Expand Up @@ -483,6 +485,7 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
_schema: &dyn ExprSchema,
arg_types: &[DataType],
) -> Result<DataType> {
#[allow(deprecated)]
self.return_type(arg_types)
}

Expand Down Expand Up @@ -756,6 +759,7 @@ impl ScalarUDFImpl for AliasedScalarUDFImpl {
}

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

Expand Down
4 changes: 3 additions & 1 deletion datafusion/functions/src/datetime/date_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ impl ScalarUDFImpl for DatePartFunc {
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
internal_err!("return_type_from_exprs shoud be called instead")
// return type could be Float32 or Int32 depending on the input arguments
// return_type_from_exprs should be called instead
Ok(DataType::Float64)
}

fn return_type_from_exprs(
Expand Down

0 comments on commit e17342c

Please sign in to comment.