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



##########
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:
       Odd, I get
   
   ```
   > iris %>% record_batch() %>%
      filter(if_any(ends_with("Width"), ~ . > 4))
   Error in if_any(ends_with("Width"), ~. > 4) : 
     could not find function "if_any"
   ```
   
   which is consistent with what I see from dplyr:
   
   ```
   > iris %>% filter(if_any(ends_with("Width"), ~ . > 4))
   Error: Problem with `filter()` input `..1`.
   ✖ could not find function "if_any"
   ℹ Input `..1` is `if_any(ends_with("Width"), ~. > 4)`.
   Run `rlang::last_error()` to see where the error occurred.
   ```




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