Skip to content

Commit

Permalink
Add docs explaining what happens when both return_type and `return_…
Browse files Browse the repository at this point in the history
…type_from_exprs` are called
  • Loading branch information
alamb committed Feb 15, 2024
1 parent e0add48 commit 653577f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datafusion/expr/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
ScalarFunctionImplementation, Signature,
};
use arrow::datatypes::DataType;
use datafusion_common::{ExprSchema, Result};
use datafusion_common::{DataFusionError, ExprSchema, Result};
use std::any::Any;
use std::fmt;
use std::fmt::Debug;
Expand Down Expand Up @@ -254,7 +254,15 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
fn signature(&self) -> &Signature;

/// What [`DataType`] will be returned by this function, given the types of
/// the arguments
/// the arguments.
///
/// # Notes
///
/// If you provide an implementation for [`Self::return_type_from_exprs`],
/// DataFusion will not call `return_type` (this function). In this case it
/// is recommended to return [`DataFusionError::Internal`].
///
/// [`DataFusionError::NotImplemented`]: datafusion_common::DataFusionError::Internal
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType>;

/// What [`DataType`] will be returned by this function, given the
Expand Down

0 comments on commit 653577f

Please sign in to comment.