You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/20 16:04:32 UTC
[GitHub] [arrow] eitsupi commented on a diff in pull request #14175: ARROW-17737: [R] Continue to retain grouping metadata even if ungroup arrow dplyr query
eitsupi commented on code in PR #14175:
URL: https://github.com/apache/arrow/pull/14175#discussion_r975560514
##########
r/R/dplyr-collect.R:
##########
@@ -60,20 +62,23 @@ restore_dplyr_features <- function(df, query) {
# An arrow_dplyr_query holds some attributes that Arrow doesn't know about
# After calling collect(), make sure these features are carried over
- if (length(query$group_by_vars) > 0) {
+ if (is.data.frame(df)) {
# Preserve groupings, if present
- if (is.data.frame(df)) {
+ if (length(query$group_by_vars) > 0) {
df <- dplyr::grouped_df(
df,
dplyr::group_vars(query),
drop = dplyr::group_by_drop_default(query)
)
+ }
+ } else {
+ # This is a Table, via compute() or collect(as_data_frame = FALSE)
+ if (length(query$group_by_vars) > 0) {
+ gv <- query$group_by_vars
} else {
- # This is a Table, via compute() or collect(as_data_frame = FALSE)
- df <- as_adq(df)
- df$group_by_vars <- query$group_by_vars
- df$drop_empty_groups <- query$drop_empty_groups
+ gv <- NULL
Review Comment:
Perhaps `restore_dplyr_features` should make sure that `df` is not grouped.
If it is guaranteed that `df` is not grouped, this case will be unnecessary.
--
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.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org