## 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/string/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
    //! "string" DataFusion functions
    19
    20
    use std::sync::Arc;
    21
    22
    use datafusion_expr::ScalarUDF;
    23
    24
    pub mod ascii;
    25
    pub mod bit_length;
    26
    pub mod btrim;
    27
    pub mod chr;
    28
    pub mod common;
    29
    pub mod concat;
    30
    pub mod concat_ws;
    31
    pub mod contains;
    32
    pub mod ends_with;
    33
    pub mod levenshtein;
    34
    pub mod lower;
    35
    pub mod ltrim;
    36
    pub mod octet_length;
    37
    pub mod overlay;
    38
    pub mod repeat;
    39
    pub mod replace;
    40
    pub mod rtrim;
    41
    pub mod split_part;
    42
    pub mod starts_with;
    43
    pub mod to_hex;
    44
    pub mod upper;
    45
    pub mod uuid;
    46
    // create UDFs
    47
    make_udf_function!(ascii::AsciiFunc, ascii);
    48
    make_udf_function!(bit_length::BitLengthFunc, bit_length);
    49
    make_udf_function!(btrim::BTrimFunc, btrim);
    50
    make_udf_function!(chr::ChrFunc, chr);
    51
    make_udf_function!(concat::ConcatFunc, concat);
    52
    make_udf_function!(concat_ws::ConcatWsFunc, concat_ws);
    53
    make_udf_function!(ends_with::EndsWithFunc, ends_with);
    54
    make_udf_function!(levenshtein::LevenshteinFunc, levenshtein);
    55
    make_udf_function!(ltrim::LtrimFunc, ltrim);
    56
    make_udf_function!(lower::LowerFunc, lower);
    57
    make_udf_function!(octet_length::OctetLengthFunc, octet_length);
    58
    make_udf_function!(repeat::RepeatFunc, repeat);
    59
    make_udf_function!(replace::ReplaceFunc, replace);
    60
    make_udf_function!(rtrim::RtrimFunc, rtrim);
    61
    make_udf_function!(starts_with::StartsWithFunc, starts_with);
    62
    make_udf_function!(split_part::SplitPartFunc, split_part);
    63
    make_udf_function!(to_hex::ToHexFunc, to_hex);
    64
    make_udf_function!(upper::UpperFunc, upper);
    65
    make_udf_function!(uuid::UuidFunc, uuid);
    66
    make_udf_function!(contains::ContainsFunc, contains);
    67
    pub mod expr_fn {
    68
        use datafusion_expr::Expr;
    69
    70
        export_functions!((
    71
            ascii,
    72
            "Returns the numeric code of the first character of the argument.",
    73
            arg1
    74
        ),(
    75
            bit_length,
    76
            "Returns the number of bits in the `string`",
    77
            arg1
    78
        ),(
    79
            btrim,
    80
            "Removes all characters, spaces by default, from both sides of a string",
    81
            args,
    82
        ),(
    83
            chr,
    84
            "Converts the Unicode code point to a UTF8 character",
    85
            arg1
    86
        ),(
    87
            concat,
    88
            "Concatenates the text representations of all the arguments. NULL arguments are ignored",
    89
            args,
    90
        ),(
    91
            ends_with,
    92
            "Returns true if the `string` ends with the `suffix`, false otherwise.",
    93
            string suffix
    94
        ),(
    95
            levenshtein,
    96
            "Returns the Levenshtein distance between the two given strings",
    97
            arg1 arg2
    98
        ),(
    99
            lower,
    100
            "Converts a string to lowercase.",
    101
            arg1
    102
        ),(
    103
            ltrim,
    104
            "Removes all characters, spaces by default, from the beginning of a string",
    105
            args,
    106
        ),(
    107
            octet_length,
    108
            "returns the number of bytes of a string",
    109
            args
    110
        ),(
    111
            repeat,
    112
            "Repeats the `string` to `n` times",
    113
            string n
    114
        ),(
    115
            replace,
    116
            "Replaces all occurrences of `from` with `to` in the `string`",
    117
            string from to
    118
        ),(
    119
            rtrim,
    120
            "Removes all characters, spaces by default, from the end of a string",
    121
            args,
    122
        ),(
    123
            split_part,
    124
            "Splits a string based on a delimiter and picks out the desired field based on the index.",
    125
            string delimiter index
    126
        ),(
    127
            starts_with,
    128
            "Returns true if string starts with prefix.",
    129
            arg1 arg2
    130
        ),(
    131
            to_hex,
    132
            "Converts an integer to a hexadecimal string.",
    133
            arg1
    134
        ),(
    135
            upper,
    136
            "Converts a string to uppercase.",
    137
            arg1
    138
        ),(
    139
            uuid,
    140
            "returns uuid v4 as a string value",
    141
        ), (
    142
            contains,
    143
            "Return true if `search_string` is found within `string`.",
    144
            string search_string
    145
        ));
    146
    147
        #[doc = "Removes all characters, spaces by default, from both sides of a string"]
    148
        pub fn trim(args: Vec<Expr>) -> Expr {
    149
            super::btrim().call(args)
    150
        }
    151
    152
        #[doc = "Concatenates all but the first argument, with separators. The first argument is used as the separator string, and should not be NULL. Other NULL arguments are ignored."]
    153
        pub fn concat_ws(delimiter: Expr, args: Vec<Expr>) -> Expr {
    154
            let mut args = args;
    155
            args.insert(0, delimiter);
    156
            super::concat_ws().call(args)
    157
        }
    158
    }
    159
    160
    /// Returns all DataFusion functions defined in this package
    161
    0
    pub fn functions() -> Vec<Arc<ScalarUDF>> {
    162
    0
        vec![
    163
    0
            ascii(),
    164
    0
            bit_length(),
    165
    0
            btrim(),
    166
    0
            chr(),
    167
    0
            concat(),
    168
    0
            concat_ws(),
    169
    0
            ends_with(),
    170
    0
            levenshtein(),
    171
    0
            lower(),
    172
    0
            ltrim(),
    173
    0
            octet_length(),
    174
    0
            repeat(),
    175
    0
            replace(),
    176
    0
            rtrim(),
    177
    0
            split_part(),
    178
    0
            starts_with(),
    179
    0
            to_hex(),
    180
    0
            upper(),
    181
    0
            uuid(),
    182
    0
            contains(),
    183
        ]
    184
    0
    }