datafusion_spark/function/string/
mod.rs

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
18pub mod ascii;
19pub mod char;
20pub mod ilike;
21pub mod like;
22pub mod luhn_check;
23
24use datafusion_expr::ScalarUDF;
25use datafusion_functions::make_udf_function;
26use std::sync::Arc;
27
28make_udf_function!(ascii::SparkAscii, ascii);
29make_udf_function!(char::CharFunc, char);
30make_udf_function!(ilike::SparkILike, ilike);
31make_udf_function!(like::SparkLike, like);
32make_udf_function!(luhn_check::SparkLuhnCheck, luhn_check);
33
34pub mod expr_fn {
35    use datafusion_functions::export_functions;
36
37    export_functions!((
38        ascii,
39        "Returns the ASCII code point of the first character of string.",
40        arg1
41    ));
42    export_functions!((
43        char,
44        "Returns the ASCII character having the binary equivalent to col. If col is larger than 256 the result is equivalent to char(col % 256).",
45        arg1
46    ));
47    export_functions!((
48        ilike,
49        "Returns true if str matches pattern (case insensitive).",
50        str pattern
51    ));
52    export_functions!((
53        like,
54        "Returns true if str matches pattern (case sensitive).",
55        str pattern
56    ));
57    export_functions!((
58        luhn_check,
59        "Returns whether the input string of digits is valid according to the Luhn algorithm.",
60        arg1
61    ));
62}
63
64pub fn functions() -> Vec<Arc<ScalarUDF>> {
65    vec![ascii(), char(), ilike(), like(), luhn_check()]
66}