Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions datafusion/functions/src/regex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod regexpinstr;
pub mod regexplike;
pub mod regexpmatch;
pub mod regexpreplace;
pub mod regexpsplittoarray;

/// Arrow's regex kernels treat null flags as no flags, but reject empty flags.
/// Normalize empty strings without copying the string buffers.
Expand All @@ -45,6 +46,10 @@ make_udf_function!(regexpinstr::RegexpInstrFunc, regexp_instr);
make_udf_function!(regexpmatch::RegexpMatchFunc, regexp_match);
make_udf_function!(regexplike::RegexpLikeFunc, regexp_like);
make_udf_function!(regexpreplace::RegexpReplaceFunc, regexp_replace);
make_udf_function!(
regexpsplittoarray::RegexpSplitToArrayFunc,
regexp_split_to_array
);

pub mod expr_fn {
use datafusion_expr::Expr;
Expand All @@ -67,6 +72,15 @@ pub mod expr_fn {
super::regexp_count().call(args)
}

/// Splits a string into an array using a regular-expression delimiter.
pub fn regexp_split_to_array(values: Expr, regex: Expr, flags: Option<Expr>) -> Expr {
let mut args = vec![values, regex];
if let Some(flags) = flags {
args.push(flags);
}
super::regexp_split_to_array().call(args)
}

/// Returns a list of regular expression matches in a string.
pub fn regexp_match(values: Expr, regex: Expr, flags: Option<Expr>) -> Expr {
let mut args = vec![values, regex];
Expand Down Expand Up @@ -136,6 +150,7 @@ pub fn functions() -> Vec<Arc<datafusion_expr::ScalarUDF>> {
regexp_instr(),
regexp_like(),
regexp_replace(),
regexp_split_to_array(),
]
}

Expand Down
Loading