jonkeane commented on a change in pull request #10724:
URL: https://github.com/apache/arrow/pull/10724#discussion_r670764086
##########
File path: r/R/dplyr-functions.R
##########
@@ -559,3 +559,24 @@ nse_funcs$wday <- function(x, label = FALSE, abbr = TRUE,
week_start = getOption
Expression$create("day_of_week", x, options = list(one_based_numbering =
TRUE, week_start = week_start))
}
+
+nse_funcs$if_else <- function(condition, true, false, missing = NULL){
+ # We ought to assert that the types of the true and false conditions will
result
+ # in the same types. We can't compare the objects themselves directly because
+ # they might be expressions (that will result in a type) or R objects that
will
+ # need to be compared to see if they are compatible with arrow types.
+ # ARROW-13186 might make this easier with a more robust way.
+ # TODO: do this ^^^
+
+ if (inherits(true, "character") || inherits(false, "character")) {
+ stop("`true` and `false` character values not yet supported in Arrow")
Review comment:
_it turns out_ only a limited set of types are supported right now
ARROW-12955 has a PR to add other types. I've added some comments + tests
around this and linked to that ticket as well. The types that are currently
supported are: Boolean, Null, Numeric, Temporal
##########
File path: r/tests/testthat/test-dplyr.R
##########
@@ -945,3 +945,63 @@ test_that("abs()", {
df
)
})
+
+test_that("if_else and ifelse", {
+ df <- tibble(x = c(-127, -10, -1, -0 , 0, 1, 10, 127, NA))
Review comment:
Here are (some of) the c++ tests, which look pretty comprehensive for
the types that are currently supported:
https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/scalar_if_else_test.cc#L49-L94
--
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]