dragosmg commented on a change in pull request #11417:
URL: https://github.com/apache/arrow/pull/11417#discussion_r729095034



##########
File path: r/R/dplyr-functions.R
##########
@@ -915,6 +915,9 @@ nse_funcs$case_when <- function(...) {
     if (!nse_funcs$is.logical(query[[i]])) {
       abort("Left side of each formula in case_when() must be a logical 
expression")
     }
+    if (inherits(value[[i]], "try-error")) {
+      abort("There is an error in the right side of the case_when() formula")

Review comment:
       Yes, 100% agree. Initially I tried to pinpoint the problem, but it's a 
bit more difficult. The other thing (related to this): do we want `case_when()` 
to work outside `mutate()`? Currently it doesn't. Error handling could be 
improved if we make `case_when()` stand alone, similar to the {dplyr} behaviour
   
   ```
   library(dplyr)
   
   num_vec <- c(1:3, 5:8)
   
   case_when(num_vec < 4 ~ "less than 4", TRUE ~ "greater than 4")
   ```          




-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to