diff --git a/r/src/compute.cpp b/r/src/compute.cpp index b2a261b0b00..994dc702e8e 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -287,7 +287,9 @@ 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") { + func_name == "match_like" || func_name == "starts_with" || + func_name == "ends_with" || func_name == "count_substring" || + func_name == "count_substring_regex") { using Options = arrow::compute::MatchSubstringOptions; bool ignore_case = false; if (!Rf_isNull(options["ignore_case"])) { diff --git a/r/tests/testthat/test-compute-no-bindings.R b/r/tests/testthat/test-compute-no-bindings.R index 0769eb416e4..30fb922d81c 100644 --- a/r/tests/testthat/test-compute-no-bindings.R +++ b/r/tests/testthat/test-compute-no-bindings.R @@ -126,3 +126,54 @@ test_that("non-bound compute kernels using PartitionNthOptions", { c(1L, 0L, 4L, 3L, 2L, 5L, 6L, 7L, 8L, 9L) ) }) + + +test_that("non-bound compute kernels using MatchSubstringOptions", { + skip_if_not_available("utf8proc") + + # Remove this test when ARROW-13924 has been completed + expect_equal( + call_function( + "starts_with", + Array$create(c("abracadabra", "abacus", "abdicate", "abrasive")), + options = list(pattern = "abr") + ), + Array$create(c(TRUE, FALSE, FALSE, TRUE)) + ) + + # Remove this test when ARROW-13924 has been completed + expect_equal( + call_function( + "ends_with", + Array$create(c("abracadabra", "abacus", "abdicate", "abrasive")), + options = list(pattern = "e") + ), + Array$create(c(FALSE, FALSE, TRUE, TRUE)) + ) + + # Remove this test when ARROW-13156 has been completed + expect_equal( + as.vector( + call_function( + "count_substring", + Array$create(c("abracadabra", "abacus", "abdicate", "abrasive")), + options = list(pattern = "e") + ) + ), + c(0, 0, 1, 1) + ) + + skip_if_not_available("re2") + + # Remove this test when ARROW-13156 has been completed + expect_equal( + as.vector( + call_function( + "count_substring_regex", + Array$create(c("abracadabra", "abacus", "abdicate", "abrasive")), + options = list(pattern = "e") + ) + ), + c(0, 0, 1, 1) + ) +})