nealrichardson commented on a change in pull request #10780:
URL: https://github.com/apache/arrow/pull/10780#discussion_r676626973



##########
File path: r/R/dplyr-summarize.R
##########
@@ -18,19 +18,24 @@
 
 # The following S3 methods are registered on load if dplyr is present
 
-summarise.arrow_dplyr_query <- function(.data, ...) {
-  call <- match.call()
-  .data <- arrow_dplyr_query(.data)
-  if (query_on_dataset(.data)) {
-    not_implemented_for_dataset("summarize()")
+summarise.arrow_dplyr_query <- function(.data, ..., .engine = c("arrow", 
"duckdb")) {
+  if (match.arg(.engine) == "duckdb") {
+    tbl <- to_duckdb(.data)
+    dplyr::summarise(tbl, ...)
+  } else {
+    call <- match.call()
+    .data <- arrow_dplyr_query(.data)
+    if (query_on_dataset(.data)) {
+      not_implemented_for_dataset("summarize()")
+    }
+    exprs <- quos(...)
+    # Only retain the columns we need to do our aggregations

Review comment:
       Good call, the way the duckdb implementation currently works, there's no 
pushdown of selection into the Arrow query from the duckdb side, so this 
optimization is something we should handle ourselves.




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


Reply via email to