@@ -34,19 +34,19 @@ use std::sync::Arc;
34
34
///
35
35
/// A scalar function produces a single row output for each row of input. This
36
36
/// 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
38
38
/// implementation.
39
39
///
40
40
/// 1. For simple use cases, use [`create_udf`] (examples in [`simple_udf.rs`]).
41
41
///
42
42
/// 2. For advanced use cases, use [`ScalarUDFImpl`] which provides full API
43
43
/// access (examples in [`advanced_udf.rs`]).
44
44
///
45
- /// See [`Self::call`] to invoke a `ScalarUDF` with arguments.
45
+ /// See [`Self::call`] to create an `Expr` which invokes a `ScalarUDF` with arguments.
46
46
///
47
47
/// # API Note
48
48
///
49
- /// This is a separate struct from `ScalarUDFImpl` to maintain backwards
49
+ /// This is a separate struct from [ `ScalarUDFImpl`] to maintain backwards
50
50
/// compatibility with the older API.
51
51
///
52
52
/// [`create_udf`]: crate::expr_fn::create_udf
@@ -568,13 +568,15 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
568
568
}
569
569
570
570
/// 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
573
575
fn short_circuits ( & self ) -> bool {
574
576
false
575
577
}
576
578
577
- /// Computes the output interval for a [`ScalarUDFImpl`], given the input
579
+ /// Computes the output [`Interval`] for a [`ScalarUDFImpl`], given the input
578
580
/// intervals.
579
581
///
580
582
/// # Parameters
@@ -590,9 +592,11 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
590
592
Interval :: make_unbounded ( & DataType :: Null )
591
593
}
592
594
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.
596
600
///
597
601
/// # Parameters
598
602
///
@@ -641,20 +645,25 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
641
645
}
642
646
}
643
647
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.
645
652
fn preserves_lex_ordering ( & self , _inputs : & [ ExprProperties ] ) -> Result < bool > {
646
653
Ok ( false )
647
654
}
648
655
649
656
/// Coerce arguments of a function call to types that the function can evaluate.
650
657
///
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.
654
661
///
655
662
/// See the [type coercion module](crate::type_coercion)
656
663
/// documentation for more details on type coercion
657
664
///
665
+ /// [`TypeSignature`]: crate::TypeSignature
666
+ ///
658
667
/// For example, if your function requires a floating point arguments, but the user calls
659
668
/// it like `my_func(1::int)` (i.e. with `1` as an integer), coerce_types can return `[DataType::Float64]`
660
669
/// to ensure the argument is converted to `1::double`
@@ -698,8 +707,8 @@ pub trait ScalarUDFImpl: Debug + Send + Sync {
698
707
699
708
/// Returns the documentation for this Scalar UDF.
700
709
///
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.
703
712
fn documentation ( & self ) -> Option < & Documentation > {
704
713
None
705
714
}
0 commit comments