Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions r/R/dplyr-summarize.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ do_arrow_summarize <- function(.data, ..., .groups = NULL) {
hash = length(.data$group_by_vars) > 0
)

# Do a projection here to keep only the columns we need in summarize().
# If possible, this will push down the column selection into the SourceNode,
# saving lots of wasted processing for columns we don't need. (GH-43627)
vars_to_keep <- unique(c(
unlist(lapply(exprs, all.vars)), # vars referenced in summarize
dplyr::group_vars(.data) # vars needed for grouping
))
.data <- dplyr::select(.data, intersect(vars_to_keep, names(.data)))

# nolint start
# summarize() is complicated because you can do a mixture of scalar operations
# and aggregations, but that's not how Acero works. For example, for us to do
Expand Down