From f7e167b285a9cbae4f88f1cfe91715eb0e965e91 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 6 Sep 2021 16:08:22 +0100 Subject: [PATCH 1/2] Implement ExtractRegexOptions --- 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 994dc702e8e..0ca6ca9f7be 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -309,6 +309,11 @@ std::shared_ptr make_compute_options( cpp11::as_cpp(options["replacement"]), max_replacements); } + + if (func_name == "extract_regex") { + using Options = arrow::compute::ExtractRegexOptions; + return std::make_shared(cpp11::as_cpp(options["pattern"])); + } if (func_name == "day_of_week") { using Options = arrow::compute::DayOfWeekOptions; diff --git a/r/tests/testthat/test-compute-no-bindings.R b/r/tests/testthat/test-compute-no-bindings.R index 30fb922d81c..f47ed12d4f8 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[a])")), + Scalar$create(tibble::tibble(letter = "a")) + ) +}) From 7f8889fffb793b9a3110fc6a6e172de046a75cc5 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 6 Sep 2021 16:20:17 +0100 Subject: [PATCH 2/2] Relint --- r/src/compute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 0ca6ca9f7be..c6ba0a28046 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -309,7 +309,7 @@ std::shared_ptr make_compute_options( cpp11::as_cpp(options["replacement"]), max_replacements); } - + if (func_name == "extract_regex") { using Options = arrow::compute::ExtractRegexOptions; return std::make_shared(cpp11::as_cpp(options["pattern"]));