ianmcook commented on a change in pull request #10737:
URL: https://github.com/apache/arrow/pull/10737#discussion_r671729110



##########
File path: r/R/dplyr-functions.R
##########
@@ -651,3 +651,47 @@ nse_funcs$log <- function(x, base = exp(1)) {
 }
 
 nse_funcs$logb <- nse_funcs$log
+
+nse_funcs$case_when <- function(...) {
+  formulas <- list2(...)
+  n <- length(formulas)
+  if (n == 0) {
+    abort("No cases provided in case_when()")
+  }
+  query <- vector("list", n)
+  value <- vector("list", n)
+  mask <- caller_env()
+  for (i in seq_len(n)) {
+    f <- formulas[[i]]
+    if (!inherits(f, "formula")) {
+      abort("Each argument to case_when() must be a two-sided formula")
+    }
+    query[[i]] <- arrow_eval(f[[2]], mask)
+    value[[i]] <- arrow_eval(f[[3]], mask)
+    if (!nse_funcs$is.logical(query[[i]])) {
+      abort("Left side of each formula in case_when() must be a logical 
expression")
+    }
+    # TODO: remove these checks after the case_when kernel supports 
variable-width
+    # types (ARROW-13222)

Review comment:
       Yep, agreed, there's really not much (any?) benefit to having these 
checks here. Removed in 2ee3c8c5909857452d89a722459127ddde723c05.




-- 
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