rok commented on a change in pull request #9758:
URL: https://github.com/apache/arrow/pull/9758#discussion_r635066765
##########
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)
+ }
+ if (FUN == "min_max" && na.rm && a$null_count == length(a)) {
+ Array$create(data.frame(min=Inf, max=-Inf))
Review comment:
```suggestion
Array$create(data.frame(min = Inf, max = -Inf))
# If na.rm == TRUE and all values in array are NA, R returns
# Inf/-Inf, which are type double. Since Arrow is type-stable
# and does not do that, we handle this special case here.
```
--
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]