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



##########
File path: r/R/dplyr.R
##########
@@ -309,8 +355,27 @@ collect.arrow_dplyr_query <- function(x, as_data_frame = 
TRUE, ...) {
     # See dataset.R for Dataset and Scanner(Builder) classes
     tab <- Scanner$create(x)$ToTable()
   } else {
-    # This is a Table/RecordBatch. See record-batch.R for the [ method
-    tab <- x$.data[x$filtered_rows, x$selected_columns, keep_na = FALSE]
+    # This is a Table or RecordBatch
+
+    # Filter and select the data referenced in selected columns
+    if (isTRUE(x$filtered_rows)) {
+      filter <- TRUE
+    } else {
+      filter <- eval_array_expression(x$filtered_rows, x$.data)
+    }
+    # TODO: shortcut if identical(names(x$.data), 
find_array_refs(x$selected_columns))?
+    tab <- x$.data[filter, find_array_refs(x$selected_columns), keep_na = 
FALSE]

Review comment:
       This line errors in this example, because `filter` is `NULL`:
   ```r
    iris %>% record_batch() %>%
      filter(if_any(ends_with("Width"), ~ . > 4))
   # Error: Cannot extract rows with an object of class NULL
   ```




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to