@@ -34,19 +34,19 @@ use std::sync::Arc;
3434///
3535/// A scalar function produces a single row output for each row of input. This
3636/// struct contains the information DataFusion needs to plan and invoke
37- /// functions you supply such name, type signature, return type, and actual
37+ /// functions you supply such as name, type signature, return type, and actual
3838/// implementation.
3939///
4040/// 1. For simple use cases, use [`create_udf`] (examples in [`simple_udf.rs`]).
4141///
4242/// 2. For advanced use cases, use [`ScalarUDFImpl`] which provides full API
4343/// access (examples in [`advanced_udf.rs`]).
4444///
45- /// See [`Self::call`] to invoke a `ScalarUDF` with arguments.
45+ /// See [`Self::call`] to create an `Expr` which invokes a `ScalarUDF` with arguments.
4646///
4747/// # API Note
4848///
49- /// This is a separate struct from `ScalarUDFImpl` to maintain backwards
49+ /// This is a separate struct from [ `ScalarUDFImpl`] to maintain backwards
5050/// compatibility with the older API.
5151///
5252/// [`create_udf`]: crate::expr_fn::create_udf
@@ -568,13 +568,15 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
568568 }
569569
570570 /// Returns true if some of this `exprs` subexpressions may not be evaluated
571- /// and thus any side effects (like divide by zero) may not be encountered
572- /// Setting this to true prevents certain optimizations such as common subexpression elimination
571+ /// and thus any side effects (like divide by zero) may not be encountered.
572+ ///
573+ /// Setting this to true prevents certain optimizations such as common
574+ /// subexpression elimination
573575 fn short_circuits ( & self ) -> bool {
574576 false
575577 }
576578
577- /// Computes the output interval for a [`ScalarUDFImpl`], given the input
579+ /// Computes the output [`Interval`] for a [`ScalarUDFImpl`], given the input
578580 /// intervals.
579581 ///
580582 /// # Parameters
@@ -590,9 +592,11 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
590592 Interval :: make_unbounded ( & DataType :: Null )
591593 }
592594
593- /// Updates bounds for child expressions, given a known interval for this
594- /// function. This is used to propagate constraints down through an expression
595- /// tree.
595+ /// Updates bounds for child expressions, given a known [`Interval`]s for this
596+ /// function.
597+ ///
598+ /// This function is used to propagate constraints down through an
599+ /// expression tree.
596600 ///
597601 /// # Parameters
598602 ///
@@ -641,20 +645,25 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
641645 }
642646 }
643647
644- /// Whether the function preserves lexicographical ordering based on the input ordering
648+ /// Returns true if the function preserves lexicographical ordering based on
649+ /// the input ordering.
650+ ///
651+ /// For example, `concat(a || b)` preserves lexicographical ordering, but `abs(a)` does not.
645652 fn preserves_lex_ordering ( & self , _inputs : & [ ExprProperties ] ) -> Result < bool > {
646653 Ok ( false )
647654 }
648655
649656 /// Coerce arguments of a function call to types that the function can evaluate.
650657 ///
651- /// This function is only called if [`ScalarUDFImpl::signature`] returns [`crate::TypeSignature::UserDefined`]. Most
652- /// UDFs should return one of the other variants of `TypeSignature` which handle common
653- /// cases
658+ /// This function is only called if [`ScalarUDFImpl::signature`] returns
659+ /// [`crate::TypeSignature::UserDefined`]. Most UDFs should return one of
660+ /// the other variants of [`TypeSignature`] which handle common cases.
654661 ///
655662 /// See the [type coercion module](crate::type_coercion)
656663 /// documentation for more details on type coercion
657664 ///
665+ /// [`TypeSignature`]: crate::TypeSignature
666+ ///
658667 /// For example, if your function requires a floating point arguments, but the user calls
659668 /// it like `my_func(1::int)` (i.e. with `1` as an integer), coerce_types can return `[DataType::Float64]`
660669 /// to ensure the argument is converted to `1::double`
@@ -698,8 +707,8 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
698707
699708 /// Returns the documentation for this Scalar UDF.
700709 ///
701- /// Documentation can be accessed programmatically as well as
702- /// generating publicly facing documentation.
710+ /// Documentation can be accessed programmatically as well as generating
711+ /// publicly facing documentation.
703712 fn documentation ( & self ) -> Option < & Documentation > {
704713 None
705714 }
0 commit comments