@@ -87,8 +87,6 @@ pub struct HigherOrderSignature {
8787 pub type_signature : HigherOrderTypeSignature ,
8888 /// The volatility of the function. See [Volatility] for more information.
8989 pub volatility : Volatility ,
90- /// Whether [HigherOrderUDF::coerce_values_for_lambdas] should be called
91- pub coerce_values_for_lambdas : bool ,
9290 /// The max number of times to call [HigherOrderUDF::lambda_parameters] before raising an error.
9391 /// Used to guard against implementations that causes an infinite loop by endlessly returning
9492 /// [LambdaParametersProgress::Partial]. Defaults to 256
@@ -103,7 +101,6 @@ impl HigherOrderSignature {
103101 HigherOrderSignature {
104102 type_signature,
105103 volatility,
106- coerce_values_for_lambdas : false ,
107104 lambda_parameters_max_iterations : LAMBDA_PARAMETERS_MAX_ITERATIONS ,
108105 }
109106 }
@@ -113,7 +110,6 @@ impl HigherOrderSignature {
113110 Self {
114111 type_signature : HigherOrderTypeSignature :: UserDefined ,
115112 volatility,
116- coerce_values_for_lambdas : false ,
117113 lambda_parameters_max_iterations : LAMBDA_PARAMETERS_MAX_ITERATIONS ,
118114 }
119115 }
@@ -123,7 +119,6 @@ impl HigherOrderSignature {
123119 Self {
124120 type_signature : HigherOrderTypeSignature :: VariadicAny ,
125121 volatility,
126- coerce_values_for_lambdas : false ,
127122 lambda_parameters_max_iterations : LAMBDA_PARAMETERS_MAX_ITERATIONS ,
128123 }
129124 }
@@ -133,18 +128,9 @@ impl HigherOrderSignature {
133128 Self {
134129 type_signature : HigherOrderTypeSignature :: Any ( arg_count) ,
135130 volatility,
136- coerce_values_for_lambdas : false ,
137131 lambda_parameters_max_iterations : LAMBDA_PARAMETERS_MAX_ITERATIONS ,
138132 }
139133 }
140-
141- /// Set [Self::coerce_values_for_lambdas] to true to indicate that [HigherOrderUDF::coerce_values_for_lambdas]
142- /// should be called
143- pub fn with_coerce_values_for_lambdas ( mut self ) -> Self {
144- self . coerce_values_for_lambdas = true ;
145-
146- self
147- }
148134}
149135
150136impl PartialEq for dyn HigherOrderUDF {
@@ -621,12 +607,12 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
621607 ///
622608 /// assert_eq!(
623609 /// coerce_to,
624- /// vec![
610+ /// Some( vec![
625611 /// // return the same type for the array being reduced
626612 /// DataType::new_list(DataType::Float32, true),
627613 /// // coerce the initial value to the output of the merge lambda
628614 /// DataType::Float32,
629- /// ]
615+ /// ])
630616 /// );
631617 ///
632618 /// ```
@@ -636,7 +622,7 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
636622 ///
637623 /// The implementation can assume that some other part of the code has coerced
638624 /// the actual argument types to match [`Self::signature`], except the coercion defined by
639- /// [Self::coerce_values_for_lambdas], if applicable .
625+ /// [Self::coerce_values_for_lambdas].
640626 ///
641627 /// [`HigherOrderFunction`]: crate::expr::HigherOrderFunction
642628 /// [`HigherOrderFunction::lambda_parameters`]: crate::expr::HigherOrderFunction::lambda_parameters
@@ -649,8 +635,7 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
649635 /// Coerce value arguments of a function call to types that the function can evaluate also taking into
650636 /// account the *output type of it's lambdas*. This differs from [HigherOrderUDF::coerce_value_types]
651637 /// that only has access to the type of it's value arguments because it's called before the output type
652- /// of lambdas are known. So that this method is called, the function must have it's
653- /// [HigherOrderSignature::coerce_values_for_lambdas] set to true
638+ /// of lambdas are known.
654639 ///
655640 /// See the [type coercion module](crate::type_coercion)
656641 /// documentation for more details on type coercion
@@ -659,29 +644,27 @@ pub trait HigherOrderUDF: Debug + DynEq + DynHash + Send + Sync + Any {
659644 /// * `fields`: The argument types of the value arguments of this function, or the output type of lambdas
660645 ///
661646 /// # Return value
662- /// A Vec with the same number of [ValueOrLambda::Value] in `fields`. DataFusion will `CAST` the
663- /// function call arguments to these specific types.
647+ /// If `Some`, contains a Vec with the same number of [ValueOrLambda::Value] in `fields`.
648+ /// DataFusion will `CAST` the function call arguments to these specific types. If `None`, no
649+ /// coercion will be applied beyond the one defined by the function signature.
664650 ///
665651 /// For example, a flexible array_reduce implementation (see [Self::lambda_parameters] docs), when working
666652 /// with the expression below, may want to coerce it's initial value argument, the *integer* `0`,
667- /// to match the output it's merge function, which is a *float*:
653+ /// to match the output of it's merge function, which is a *float*:
668654 ///
669655 /// `array_reduce([1.2, 2.1], 0, (acc, v) -> acc + v + 1.5, v -> v > 2.0)`
670656 fn coerce_values_for_lambdas (
671657 & self ,
672658 _fields : & [ ValueOrLambda < DataType , DataType > ] ,
673- ) -> Result < Vec < DataType > > {
674- not_impl_err ! (
675- "{} coerce_values_for_lambdas is not implemented" ,
676- self . name( )
677- )
659+ ) -> Result < Option < Vec < DataType > > > {
660+ Ok ( None )
678661 }
679662
680663 /// What type will be returned by this function, given the arguments?
681664 ///
682665 /// The implementation can assume that some other part of the code has coerced
683666 /// the actual argument types to match [`Self::signature`], including the coercion
684- /// defined by [Self::coerce_values_for_lambdas], if applicable .
667+ /// defined by [Self::coerce_values_for_lambdas].
685668 ///
686669 /// # Example creating `Field`
687670 ///
0 commit comments