Skip to content
Closed
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
1 change: 1 addition & 0 deletions r/src/compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
}

if (func_name == "match_substring" || func_name == "match_substring_regex" ||
func_name == "find_substring" || func_name == "find_substring_regex" ||
func_name == "match_like") {
using Options = arrow::compute::MatchSubstringOptions;
bool ignore_case = false;
Expand Down
43 changes: 43 additions & 0 deletions r/tests/testthat/test-dplyr-string-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,49 @@ test_that("errors in strptime", {
)
})

test_that("arrow_find_substring and arrow_find_substring_regex", {

df <- tibble(x = c("Foo and Bar", "baz and qux and quux"))

expect_equivalent(
df %>%
Table$create() %>%
mutate(x = arrow_find_substring(x, options = list(pattern = "b"))) %>%
collect(),
tibble(x = c(-1, 0))
)
expect_equivalent(
df %>%
Table$create() %>%
mutate(x = arrow_find_substring(
x,
options = list(pattern = "b", ignore_case = TRUE)
)) %>%
collect(),
tibble(x = c(8, 0))
)
expect_equivalent(
df %>%
Table$create() %>%
mutate(x = arrow_find_substring_regex(
x,
options = list(pattern = "^[fb]")
)) %>%
collect(),
tibble(x = c(-1, 0))
)
expect_equivalent(
df %>%
Table$create() %>%
mutate(x = arrow_find_substring_regex(
x,
options = list(pattern = "[AEIOU]", ignore_case = TRUE)
)) %>%
collect(),
tibble(x = c(1, 1))
)
})

test_that("stri_reverse and arrow_ascii_reverse functions", {

df_ascii <- tibble(x = c("Foo\nand bar", "baz\tand qux and quux"))
Expand Down