nealrichardson commented on a change in pull request #11357:
URL: https://github.com/apache/arrow/pull/11357#discussion_r724980827



##########
File path: r/R/compute.R
##########
@@ -49,6 +49,11 @@ call_function <- function(function_name, ..., args = 
list(...), options = empty_
 
   datum_classes <- c("Array", "ChunkedArray", "RecordBatch", "Table", "Scalar")
   valid_args <- map_lgl(args, ~ inherits(., datum_classes))
+
+  if (function_name == "index") {
+    options$value <- Scalar$create(options$value)
+  }
+

Review comment:
       Let's leave the burden on the user for this, just like we do for all of 
the other kernels (`call_function` is too low level to handle this)
   
   ```suggestion
   ```

##########
File path: r/tests/testthat/test-compute-no-bindings.R
##########
@@ -190,3 +190,12 @@ test_that("non-bound compute kernels using 
ExtractRegexOptions", {
     Scalar$create(tibble::tibble(letter = "a"))
   )
 })
+
+test_that("non-bound compute kernels using IndexOptions", {
+  expect_equal(
+    as.vector(
+      call_function("index", Array$create(c(10, 20, 30, 40)), options = 
list(value = 40))

Review comment:
       ```suggestion
         call_function("index", Array$create(c(10, 20, 30, 40)), options = 
list(value = Scalar$create(40)))
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to