Skip to content

Commit 8f3b0fe

Browse files
committed
clarify difference between HigherOrderUDF coerce_value_types and coerce_values_for_lambdas
1 parent 15a0106 commit 8f3b0fe

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

datafusion/expr/src/higher_order_function.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,9 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
521521

522522
/// Coerce value arguments of a function call to types that the function can evaluate also taking into
523523
/// account the *output type of it's lambdas*. This differs from [HigherOrderUDF::coerce_value_types]
524-
/// that only has access to the type of it's value arguments. So that this method is called, the
525-
/// function must have it's [HigherOrderSignature::coerce_values_for_lambdas] set to true
524+
/// that only has access to the type of it's value arguments because it's called before the output type
525+
/// of lambdas are known. So that this method is called, the function must have it's
526+
/// [HigherOrderSignature::coerce_values_for_lambdas] set to true
526527
///
527528
/// See the [type coercion module](crate::type_coercion)
528529
/// documentation for more details on type coercion
@@ -646,6 +647,9 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
646647
}
647648

648649
/// Coerce value arguments of a function call to types that the function can evaluate.
650+
/// Note that if you need to coerce values based on the output type of lambdas, you
651+
/// must use [HigherOrderUDF::coerce_values_for_lambdas], as this function is used before
652+
/// the output type of lambdas are known
649653
///
650654
/// See the [type coercion module](crate::type_coercion)
651655
/// documentation for more details on type coercion

datafusion/sql/src/expr/function.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
412412
})
413413
.collect::<Result<Vec<_>>>()?;
414414

415+
// coerce fields because coercion may alter the lambda parameters
415416
let mut fields =
416417
value_fields_with_higher_order_udf(&current_fields, fm.as_ref())?
417418
.into_iter()

0 commit comments

Comments
 (0)