Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-43627: [R] Fix summarize() performance regression (pushdown) #43649

Merged
merged 1 commit into from
Aug 14, 2024
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
Loading