rok commented on a change in pull request #9758:
URL: https://github.com/apache/arrow/pull/9758#discussion_r635065386
##########
File path: r/R/compute.R
##########
@@ -110,15 +114,16 @@ max.ArrowDatum <- function(..., na.rm = FALSE) {
scalar_aggregate("min_max", ..., na.rm = na.rm)$GetFieldByName("max")
}
-scalar_aggregate <- function(FUN, ..., na.rm = FALSE) {
+scalar_aggregate <- function(FUN, ..., na.rm = FALSE, na.min_count = 0) {
a <- collect_arrays_from_dots(list(...))
- if (!na.rm && a$null_count > 0 && (FUN %in% c("mean", "sum"))) {
- # Arrow sum/mean function always drops NAs so handle that here
- # https://issues.apache.org/jira/browse/ARROW-9054
- return(Scalar$create(NA_real_))
+ if (FUN %in% c("mean", "sum") && !na.rm) {
+ na.min_count = length(a)
Review comment:
```suggestion
if (!na.rm) {
# When not removing null values, we require all values to be not null
and
# return null otherwise. We do that by setting minimum count of non-null
# option values to the full array length.
na.min_count <- length(a)
```
--
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]