jonkeane commented on a change in pull request #12073:
URL: https://github.com/apache/arrow/pull/12073#discussion_r779656272
##########
File path: r/R/metadata.R
##########
@@ -133,24 +133,24 @@ remove_attributes <- function(x) {
}
arrow_attributes <- function(x, only_top_level = FALSE) {
+
+ att <- attributes(x)
+ removed_attributes <- remove_attributes(x)
+
if (inherits(x, "grouped_df")) {
# Keep only the group var names, not the rest of the cached data that dplyr
# uses, which may be large
if (requireNamespace("dplyr", quietly = TRUE)) {
gv <- dplyr::group_vars(x)
x <- dplyr::ungroup(x)
# ungroup() first, then set attribute, bc ungroup() would erase it
- attr(x, ".group_vars") <- gv
- } else {
- # Regardless, we shouldn't keep groups around
- attr(x, "groups") <- NULL
+ att[[".group_vars"]] <- gv
+ removed_attributes <- c(removed_attributes, "groups", "class")
Review comment:
Aaaah, I missed that `identical()` bit there the first time I was
reading. I presume one of the branches you tried was something like
`all(c("tbl_df", "tbl", "data.frame") %in% class(x)))` and that didn't work?
I'm fine to keep it here if that doesn't work (/ causes other issues).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]