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 2021/05/07 03:06:18 UTC

[GitHub] [arrow] ianmcook commented on a change in pull request #10261: ARROW-11769: [R] Pull groups from grouped_df into RecordBatch or Table

ianmcook commented on a change in pull request #10261:
URL: https://github.com/apache/arrow/pull/10261#discussion_r627893108



##########
File path: r/R/record-batch.R
##########
@@ -148,13 +148,20 @@ RecordBatch$create <- function(..., schema = NULL) {
   if (length(arrays) == 1 && inherits(arrays[[1]], c("raw", "Buffer", "InputStream", "Message"))) {
     return(RecordBatch$from_message(arrays[[1]], schema))
   }
+  
   # Else, list of arrays
   # making sure there are always names
   if (is.null(names(arrays))) {
     names(arrays) <- rep_len("", length(arrays))
   }
   stopifnot(length(arrays) > 0)
 
+  # Preserve any grouping
+  if (length(arrays) == 1 && inherits(arrays[[1]], "grouped_df")) {
+    out <- RecordBatch__from_arrays(schema, arrays)
+    return(group_by(out, !!!groups(arrays[[1]])))

Review comment:
       dplyr is not in Arrow's Depends or Imports, so we need to use `dplyr::` before `group_by` and other dplyr functions. This line will error if dplyr is not installed, but that's reasonable because it's enclosed in a conditional that should prevent it from being run in most cases where dplyr is not installed 
   ```suggestion
       return(dplyr::group_by(out, !!!groups(arrays[[1]])))
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org