diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 01bc684c6df..9a05dd02859 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -233,6 +233,7 @@ std::shared_ptr 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; diff --git a/r/tests/testthat/test-dplyr-string-functions.R b/r/tests/testthat/test-dplyr-string-functions.R index 4cb07c9e39d..ecbe2f00f2d 100644 --- a/r/tests/testthat/test-dplyr-string-functions.R +++ b/r/tests/testthat/test-dplyr-string-functions.R @@ -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"))