Skip to content

Commit

Permalink
fix flags types
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashenC committed Nov 20, 2024
1 parent c3f9889 commit 3b0c412
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion datafusion/functions/src/regex/regexplike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,34 @@ pub fn regexp_like(args: &[ArrayRef]) -> Result<ArrayRef> {
match args.len() {
2 => handle_regexp_like(&args[0], &args[1], None),
3 => {
let flags = args[2].as_string::<i32>();
let flags = match args[2].data_type() {
Utf8 => args[2].as_string::<i32>(),
LargeUtf8 => {
let large_string_array = args[2].as_string::<i64>();
let string_vec: Vec<Option<&str>> = (0..large_string_array.len()).map(|i| {
if large_string_array.is_null(i) {
None
} else {
Some(large_string_array.value(i))
}
})
.collect();

&GenericStringArray::<i32>::from(string_vec)
},
_ => {
let string_view_array = args[2].as_string_view();
let string_vec: Vec<Option<String>> = (0..string_view_array.len()).map(|i| {
if string_view_array.is_null(i) {
None
} else {
Some(string_view_array.value(i).to_string())
}
})
.collect();
&GenericStringArray::<i32>::from(string_vec)
},
};

if flags.iter().any(|s| s == Some("g")) {
return plan_err!("regexp_like() does not support the \"global\" option");
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/string/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ EXPLAIN SELECT
FROM test;
----
logical_plan
01)Projection: regexp_like(test.column1_utf8view, Utf8("^https?://(?:www\.)?([^/]+)/.*$")) AS k
01)Projection: regexp_like(test.column1_utf8view, Utf8View("^https?://(?:www\.)?([^/]+)/.*$")) AS k
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for REGEXP_MATCH
Expand Down

0 comments on commit 3b0c412

Please sign in to comment.