datafusion_functions/regex/
mod.rs1use std::sync::Arc;
21
22pub mod regexpcount;
23pub mod regexplike;
24pub mod regexpmatch;
25pub mod regexpreplace;
26
27make_udf_function!(regexpcount::RegexpCountFunc, regexp_count);
29make_udf_function!(regexpmatch::RegexpMatchFunc, regexp_match);
30make_udf_function!(regexplike::RegexpLikeFunc, regexp_like);
31make_udf_function!(regexpreplace::RegexpReplaceFunc, regexp_replace);
32
33pub mod expr_fn {
34 use datafusion_expr::Expr;
35
36 pub fn regexp_count(
38 values: Expr,
39 regex: Expr,
40 start: Option<Expr>,
41 flags: Option<Expr>,
42 ) -> Expr {
43 let mut args = vec![values, regex];
44 if let Some(start) = start {
45 args.push(start);
46 };
47
48 if let Some(flags) = flags {
49 args.push(flags);
50 };
51 super::regexp_count().call(args)
52 }
53
54 pub fn regexp_match(values: Expr, regex: Expr, flags: Option<Expr>) -> Expr {
56 let mut args = vec![values, regex];
57 if let Some(flags) = flags {
58 args.push(flags);
59 };
60 super::regexp_match().call(args)
61 }
62
63 pub fn regexp_like(values: Expr, regex: Expr, flags: Option<Expr>) -> Expr {
65 let mut args = vec![values, regex];
66 if let Some(flags) = flags {
67 args.push(flags);
68 };
69 super::regexp_like().call(args)
70 }
71
72 pub fn regexp_replace(
74 string: Expr,
75 pattern: Expr,
76 replacement: Expr,
77 flags: Option<Expr>,
78 ) -> Expr {
79 let mut args = vec![string, pattern, replacement];
80 if let Some(flags) = flags {
81 args.push(flags);
82 };
83 super::regexp_replace().call(args)
84 }
85}
86
87pub fn functions() -> Vec<Arc<datafusion_expr::ScalarUDF>> {
89 vec![
90 regexp_count(),
91 regexp_match(),
92 regexp_like(),
93 regexp_replace(),
94 ]
95}