You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by th...@apache.org on 2021/09/14 10:56:11 UTC

[arrow] branch master updated: ARROW-13908: [R] Implement ExtractRegexOptions

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 8875d5c  ARROW-13908: [R] Implement ExtractRegexOptions
8875d5c is described below

commit 8875d5c091fed92aa40150a33a3c00875d97376e
Author: Nic Crane <th...@gmail.com>
AuthorDate: Tue Sep 14 11:54:02 2021 +0100

    ARROW-13908: [R] Implement ExtractRegexOptions
    
    Closes #11098 from thisisnic/ARROW-13908_extract_regex_options
    
    Authored-by: Nic Crane <th...@gmail.com>
    Signed-off-by: Nic Crane <th...@gmail.com>
---
 r/src/compute.cpp                           | 5 +++++
 r/tests/testthat/test-compute-no-bindings.R | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/r/src/compute.cpp b/r/src/compute.cpp
index 994dc70..c6ba0a2 100644
--- a/r/src/compute.cpp
+++ b/r/src/compute.cpp
@@ -310,6 +310,11 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
                                      max_replacements);
   }
 
+  if (func_name == "extract_regex") {
+    using Options = arrow::compute::ExtractRegexOptions;
+    return std::make_shared<Options>(cpp11::as_cpp<std::string>(options["pattern"]));
+  }
+
   if (func_name == "day_of_week") {
     using Options = arrow::compute::DayOfWeekOptions;
     bool one_based_numbering = true;
diff --git a/r/tests/testthat/test-compute-no-bindings.R b/r/tests/testthat/test-compute-no-bindings.R
index 30fb922..f47ed12 100644
--- a/r/tests/testthat/test-compute-no-bindings.R
+++ b/r/tests/testthat/test-compute-no-bindings.R
@@ -177,3 +177,11 @@ test_that("non-bound compute kernels using MatchSubstringOptions", {
     c(0, 0, 1, 1)
   )
 })
+
+test_that("non-bound compute kernels using ExtractRegexOptions", {
+  skip_if_not_available("re2")
+  expect_equal(
+    call_function("extract_regex", Scalar$create("abracadabra"), options = list(pattern = "(?P<letter>[a])")),
+    Scalar$create(tibble::tibble(letter = "a"))
+  )
+})