## Coverage Report

#### Created: 2025-11-22 06:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /Users/andrewlamb/Software/datafusion/datafusion/functions/src/unicode/mod.rs

    Line
    Count
    Source
    1
    // Licensed to the Apache Software Foundation (ASF) under one
    2
    // or more contributor license agreements.  See the NOTICE file
    3
    // distributed with this work for additional information
    4
    // regarding copyright ownership.  The ASF licenses this file
    5
    // to you under the Apache License, Version 2.0 (the
    6
    // "License"); you may not use this file except in compliance
    7
    // with the License.  You may obtain a copy of the License at
    8
    //
    9
    //   http://www.apache.org/licenses/LICENSE-2.0
    10
    //
    11
    // Unless required by applicable law or agreed to in writing,
    12
    // software distributed under the License is distributed on an
    13
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14
    // KIND, either express or implied.  See the License for the
    15
    // specific language governing permissions and limitations
    16
    // under the License.
    17
    18
    //! "unicode" DataFusion functions
    19
    20
    use std::sync::Arc;
    21
    22
    use datafusion_expr::ScalarUDF;
    23
    24
    pub mod character_length;
    25
    pub mod find_in_set;
    26
    pub mod initcap;
    27
    pub mod left;
    28
    pub mod lpad;
    29
    pub mod planner;
    30
    pub mod reverse;
    31
    pub mod right;
    32
    pub mod rpad;
    33
    pub mod strpos;
    34
    pub mod substr;
    35
    pub mod substrindex;
    36
    pub mod translate;
    37
    38
    // create UDFs
    39
    make_udf_function!(character_length::CharacterLengthFunc, character_length);
    40
    make_udf_function!(find_in_set::FindInSetFunc, find_in_set);
    41
    make_udf_function!(initcap::InitcapFunc, initcap);
    42
    make_udf_function!(left::LeftFunc, left);
    43
    make_udf_function!(lpad::LPadFunc, lpad);
    44
    make_udf_function!(right::RightFunc, right);
    45
    make_udf_function!(reverse::ReverseFunc, reverse);
    46
    make_udf_function!(rpad::RPadFunc, rpad);
    47
    make_udf_function!(strpos::StrposFunc, strpos);
    48
    make_udf_function!(substr::SubstrFunc, substr);
    49
    make_udf_function!(substr::SubstrFunc, substring);
    50
    make_udf_function!(substrindex::SubstrIndexFunc, substr_index);
    51
    make_udf_function!(translate::TranslateFunc, translate);
    52
    53
    pub mod expr_fn {
    54
        use datafusion_expr::Expr;
    55
    56
        export_functions!((
    57
            character_length,
    58
            "the number of characters in the `string`",
    59
            string
    60
        ),(
    61
            lpad,
    62
            "fill up a string to the length by prepending the characters",
    63
            args,
    64
        ),(
    65
            rpad,
    66
            "fill up a string to the length by appending the characters",
    67
            args,
    68
        ),(
    69
            reverse,
    70
            "reverses the `string`",
    71
            string
    72
        ),(
    73
            substr,
    74
            "substring from the `position` to the end",
    75
            string position
    76
        ),(
    77
            substr_index,
    78
            "Returns the substring from str before count occurrences of the delimiter",
    79
            string delimiter count
    80
        ),(
    81
            strpos,
    82
            "finds the position from where the `substring` matches the `string`",
    83
            string substring
    84
        ),(
    85
            substring,
    86
            "substring from the `position` with `length` characters",
    87
            string position length
    88
        ),(
    89
            translate,
    90
            "replaces the characters in `from` with the counterpart in `to`",
    91
            string from to
    92
        ),(
    93
            right,
    94
            "returns the last `n` characters in the `string`",
    95
            string n
    96
        ),(
    97
            left,
    98
            "returns the first `n` characters in the `string`",
    99
            string n
    100
        ),(
    101
            initcap,
    102
            "converts the first letter of each word in `string` in uppercase and the remaining characters in lowercase",
    103
            string
    104
        ),(
    105
            find_in_set,
    106
            "Returns a value in the range of 1 to N if the string `str` is in the string list `strlist` consisting of N substrings",
    107
            string strlist
    108
        ));
    109
    110
        #[doc = "the number of characters in the `string`"]
    111
        pub fn char_length(string: Expr) -> Expr {
    112
            character_length(string)
    113
        }
    114
    115
        #[doc = "finds the position from where the `substring` matches the `string`"]
    116
        pub fn instr(string: Expr, substring: Expr) -> Expr {
    117
            strpos(string, substring)
    118
        }
    119
    120
        #[doc = "the number of characters in the `string`"]
    121
        pub fn length(string: Expr) -> Expr {
    122
            character_length(string)
    123
        }
    124
    125
        #[doc = "finds the position from where the `substring` matches the `string`"]
    126
        pub fn position(string: Expr, substring: Expr) -> Expr {
    127
            strpos(string, substring)
    128
        }
    129
    }
    130
    131
    /// Returns all DataFusion functions defined in this package
    132
    0
    pub fn functions() -> Vec<Arc<ScalarUDF>> {
    133
    0
        vec![
    134
    0
            character_length(),
    135
    0
            find_in_set(),
    136
    0
            initcap(),
    137
    0
            left(),
    138
    0
            lpad(),
    139
    0
            reverse(),
    140
    0
            right(),
    141
    0
            rpad(),
    142
    0
            strpos(),
    143
    0
            substr(),
    144
    0
            substr_index(),
    145
    0
            translate(),
    146
        ]
    147
    0
    }