From 3670e6045338e4a941ad88fe5931af9f74ba3bc3 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 6 Sep 2021 13:14:46 +0100 Subject: [PATCH] Add bindings for partitionnthoptions --- 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 7698fdeee90..b2a261b0b00 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -437,6 +437,11 @@ std::shared_ptr make_compute_options( return out; } + if (func_name == "partition_nth_indices") { + using Options = arrow::compute::PartitionNthOptions; + return std::make_shared(cpp11::as_cpp(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 ecd54f51090..0769eb416e4 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) + ) +})