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



##########
File path: r/R/compute.R
##########
@@ -186,6 +186,32 @@ unique.ArrowDatum <- function(x, incomparables = FALSE, 
...) {
   call_function("unique", x)
 }
 
+#' @export
+any.ArrowDatum <- function(..., na.rm = FALSE){
+  
+  a <- collect_arrays_from_dots(list(...))
+  result <- call_function("any", a)
+
+  if(!na.rm && a$null_count > 0 && !as.vector(result)){
+    Scalar$create(NA)

Review comment:
       ```suggestion
     if (!na.rm && a$null_count > 0 && !as.vector(result)) {
       # Three-valued logic: with na.rm = FALSE, any(c(TRUE, NA)) returns TRUE 
but any(c(FALSE, NA)) returns NA
       # TODO: C++ library should take na.rm for any/all (like ARROW-9054)
       Scalar$create(NA)
   ```
   
   FYI @rok, not sure if you want to add this to your PR for ARROW-9054 or if 
you'd like to do a followup to add any/all to it, up to you.

##########
File path: r/R/compute.R
##########
@@ -186,6 +186,32 @@ unique.ArrowDatum <- function(x, incomparables = FALSE, 
...) {
   call_function("unique", x)
 }
 
+#' @export
+any.ArrowDatum <- function(..., na.rm = FALSE){
+  
+  a <- collect_arrays_from_dots(list(...))
+  result <- call_function("any", a)
+
+  if(!na.rm && a$null_count > 0 && !as.vector(result)){
+    Scalar$create(NA)
+  } else {
+    result
+  }
+}
+
+#' @export
+all.ArrowDatum <- function(..., na.rm = FALSE){
+  
+  a <- collect_arrays_from_dots(list(...))
+  result <- call_function("all", a)
+  
+  if(!na.rm &&  a$null_count > 0 && as.vector(result)){

Review comment:
       ```suggestion
     if (!na.rm && a$null_count > 0 && as.vector(result)) {
       # See comment above in any() about three-valued logic
   ```




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

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


Reply via email to