Apache DataFusion SQL Query Engine
Clarify documentation that ScalarUDFImpl::simplity must not change the schema (#17981)
Andrew Lamb37ad8a5418a3
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rsindex fa71a76c09..bfd699d814 100644--- a/datafusion/expr/src/udaf.rs+++ b/datafusion/expr/src/udaf.rs@@ -671,6 +671,13 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {////// closure returns simplified [Expr] or an error.///+ /// # Notes+ ///+ /// The returned expression must have the same schema as the original+ /// expression, including both the data type and nullability. For example,+ /// if the original expression is nullable, the returned expression must+ /// also be nullable, otherwise it may lead to schema verification errors+ /// later in query planning.fn simplify(&self) -> Option<AggregateFunctionSimplification> {None}diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rsindex bc9e62fe62..d522158f7b 100644--- a/datafusion/expr/src/udf.rs+++ b/datafusion/expr/src/udf.rs@@ -635,6 +635,14 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send + Sync {/// [`ExprSimplifyResult`] indicating the result of the simplification NOTE/// if the function cannot be simplified, the arguments *MUST* be returned/// unmodified+ ///+ /// # Notes+ ///+ /// The returned expression must have the same schema as the original+ /// expression, including both the data type and nullability. For example,+ /// if the original expression is nullable, the returned expression must+ /// also be nullable, otherwise it may lead to schema verification errors+ /// later in query planning.fn simplify(&self,args: Vec<Expr>,diff --git a/datafusion/expr/src/udwf.rs b/datafusion/expr/src/udwf.rsindex 402add0391..abe3df6375 100644--- a/datafusion/expr/src/udwf.rs+++ b/datafusion/expr/src/udwf.rs@@ -358,6 +358,13 @@ pub trait WindowUDFImpl: Debug + DynEq + DynHash + Send + Sync {/// Or, a closure with two arguments:/// * 'window_function': [crate::expr::WindowFunction] for which simplified has been invoked/// * 'info': [crate::simplify::SimplifyInfo]+ ///+ /// # Notes+ /// The returned expression must have the same schema as the original+ /// expression, including both the data type and nullability. For example,+ /// if the original expression is nullable, the returned expression must+ /// also be nullable, otherwise it may lead to schema verification errors+ /// later in query planning.fn simplify(&self) -> Option<WindowFunctionSimplification> {None}