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 0b6f531  ARROW-13906: [R] Implement PartitionNthOptions
0b6f531 is described below

commit 0b6f531f89ef897131dbee5921908f5a8f169548
Author: Nic Crane <[email protected]>
AuthorDate: Tue Sep 14 07:25:39 2021 +0100

    ARROW-13906: [R] Implement PartitionNthOptions
    
    Closes #11094 from thisisnic/ARROW-13905_partitionnthoptions
    
    Authored-by: Nic Crane <[email protected]>
    Signed-off-by: Nic Crane <[email protected]>
---
 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 7698fde..b2a261b 100644
--- a/r/src/compute.cpp
+++ b/r/src/compute.cpp
@@ -437,6 +437,11 @@ std::shared_ptr<arrow::compute::FunctionOptions> 
make_compute_options(
     return out;
   }
 
+  if (func_name == "partition_nth_indices") {
+    using Options = arrow::compute::PartitionNthOptions;
+    return std::make_shared<Options>(cpp11::as_cpp<int64_t>(options["pivot"]));
+  }
+
   return nullptr;
 }
 
diff --git a/r/tests/testthat/test-compute-no-bindings.R 
b/r/tests/testthat/test-compute-no-bindings.R
index ecd54f5..0769eb4 100644
--- a/r/tests/testthat/test-compute-no-bindings.R
+++ b/r/tests/testthat/test-compute-no-bindings.R
@@ -103,6 +103,7 @@ test_that("non-bound compute kernels using 
ReplaceSliceOptions", {
     Array$create("I don't need to fix this string")
   )
 })
+
 test_that("non-bound compute kernels using ModeOptions", {
   expect_equal(
     as.vector(
@@ -118,3 +119,10 @@ test_that("non-bound compute kernels using ModeOptions", {
     tibble::tibble("mode" = numeric(), "count" = integer())
   )
 })
+
+test_that("non-bound compute kernels using PartitionNthOptions", {
+  expect_equal(
+    as.vector(call_function("partition_nth_indices", Array$create(c(1:10)), 
options = list(pivot = 5))),
+    c(1L, 0L, 4L, 3L, 2L, 5L, 6L, 7L, 8L, 9L)
+  )
+})

Reply via email to