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



##########
File path: r/R/dplyr-functions.R
##########
@@ -57,6 +57,46 @@ nse_funcs$cast <- function(x, target_type, safe = TRUE, ...) 
{
   Expression$create("cast", x, options = opts)
 }
 
+nse_funcs$coalesce <- function(...) {
+  if (missing(..1)) {
+    abort("At least one argument must be supplied to coalesce()")
+  }
+
+  # treat NaN like NA for consistency with dplyr::coalesce()
+  # TODO: if an option is added to the coalesce kernel to treat NaN as NA,
+  # use that to simplify the code here (ARROW-13389)
+  args <- list2(...)
+  # if *all* the values are NaN, we should return NaN, not NA, so don't replace
+  # NaN with NA in the final (or only) argument

Review comment:
       Slight reorganization for readability
   
   ```suggestion
     args <- list2(...)
     if (length(args) < 1) {
       abort("At least one argument must be supplied to coalesce()")
     }
   
     # Treat NaN like NA for consistency with dplyr::coalesce():
     # if *all* the values are NaN, we should return NaN, not NA, so don't 
replace
     # NaN with NA in the final (or only) argument
     # TODO: if an option is added to the coalesce kernel to treat NaN as NA,
     # use that to simplify the code here (ARROW-13389)
   ```




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