Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions r/src/compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
step);
}

if (func_name == "utf8_replace_slice" || func_name == "binary_replace_slice") {
using Options = arrow::compute::ReplaceSliceOptions;

return std::make_shared<Options>(cpp11::as_cpp<int64_t>(options["start"]),
cpp11::as_cpp<int64_t>(options["stop"]),
cpp11::as_cpp<std::string>(options["replacement"]));
}

if (func_name == "variance" || func_name == "stddev" || func_name == "hash_variance" ||
func_name == "hash_stddev") {
using Options = arrow::compute::VarianceOptions;
Expand Down
23 changes: 22 additions & 1 deletion r/tests/testthat/test-compute-no-bindings.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


test_that("non-bound compute kernels using TrimOptions", {
skip_if_not_available("utf8proc")
skip_if_not_available("utf8proc")
expect_equal(
call_function(
"utf8_trim",
Expand Down Expand Up @@ -82,6 +82,27 @@ skip_if_not_available("utf8proc")
)
})

test_that("non-bound compute kernels using ReplaceSliceOptions", {
skip_if_not_available("utf8proc")

expect_equal(
call_function(
"binary_replace_slice",
Array$create("I need to fix this string"),
options = list(start = 1, stop = 1, replacement = " don't")
),
Array$create("I don't need to fix this string")
)

expect_equal(
call_function(
"utf8_replace_slice",
Array$create("I need to fix this string"),
options = list(start = 1, stop = 1, replacement = " don't")
),
Array$create("I don't need to fix this string")
)
})
test_that("non-bound compute kernels using ModeOptions", {
expect_equal(
as.vector(
Expand Down