From 4a031ed789070062c6d3d113f98eb46e7c50e172 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Sun, 15 Aug 2021 20:54:08 -0400 Subject: [PATCH] Fix NSE on aggregations --- r/R/arrowExports.R | 1 - r/R/dplyr-eval.R | 6 +++++- r/tests/testthat/test-dplyr-aggregate.R | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R index 4e1e4dcb859..2237f818ee0 100644 --- a/r/R/arrowExports.R +++ b/r/R/arrowExports.R @@ -1771,4 +1771,3 @@ SetIOThreadPoolCapacity <- function(threads) { Array__infer_type <- function(x) { .Call(`_arrow_Array__infer_type`, x) } - diff --git a/r/R/dplyr-eval.R b/r/R/dplyr-eval.R index 3a1261602a3..89eec94e4d2 100644 --- a/r/R/dplyr-eval.R +++ b/r/R/dplyr-eval.R @@ -87,7 +87,11 @@ arrow_mask <- function(.data, aggregation = FALSE) { } if (aggregation) { - f_env <- new_environment(agg_funcs, parent = f_env) + # This should probably be done with an environment inside an environment + # but a first attempt at that had scoping problems (ARROW-13499) + for (f in names(agg_funcs)) { + f_env[[f]] <- agg_funcs[[f]] + } } # Assign the schema to the expressions diff --git a/r/tests/testthat/test-dplyr-aggregate.R b/r/tests/testthat/test-dplyr-aggregate.R index ef2929ee65b..25cd0ccabfb 100644 --- a/r/tests/testthat/test-dplyr-aggregate.R +++ b/r/tests/testthat/test-dplyr-aggregate.R @@ -146,11 +146,10 @@ test_that("Group by any/all", { collect(), tbl ) - skip("This seems to be calling base::nchar") expect_dplyr_equal( input %>% group_by(some_grouping) %>% - summarize(has_words = all(nchar(verses) < 0)) %>% + summarize(has_words = all(nchar(verses) < 0, na.rm = TRUE)) %>% arrange(some_grouping) %>% collect(), tbl