This is an automated email from the ASF dual-hosted git repository.
thisisnic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 672149b ARROW-13869: [R] Implement options for non-bound
MatchSubstringOptions kernels
672149b is described below
commit 672149b68f3c8878e0f62a1bfde122092d734c0d
Author: Nic Crane <[email protected]>
AuthorDate: Tue Sep 14 08:36:49 2021 +0100
ARROW-13869: [R] Implement options for non-bound MatchSubstringOptions
kernels
Closes #11102 from thisisnic/ARROW-13869_misc_compute
Authored-by: Nic Crane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
---
r/src/compute.cpp | 4 ++-
r/tests/testthat/test-compute-no-bindings.R | 51 +++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/r/src/compute.cpp b/r/src/compute.cpp
index b2a261b..994dc70 100644
--- a/r/src/compute.cpp
+++ b/r/src/compute.cpp
@@ -287,7 +287,9 @@ 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") {
+ 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 0769eb4..30fb922 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)
+ )
+})