bkietz commented on a change in pull request #10191:
URL: https://github.com/apache/arrow/pull/10191#discussion_r628305534



##########
File path: r/R/dplyr.R
##########
@@ -58,40 +63,36 @@ arrow_dplyr_query <- function(.data) {
   )
 }
 
+make_field_refs <- function(field_names) {
+  set_names(lapply(field_names, Expression$field_ref), field_names)
+}
+
 #' @export
 print.arrow_dplyr_query <- function(x, ...) {
   schm <- x$.data$schema
-  cols <- get_field_names(x)
-  # If cols are expressions, they won't be in the schema and will be "" in cols
-  fields <- map_chr(cols, function(name) {
+  fields <- map_chr(x$selected_columns, function(expr) {
+    name <- expr$field_name
     if (nzchar(name)) {
       schm$GetFieldByName(name)$ToString()
     } else {
+      # It's "" because this is not a field_ref, it's a more complex expression
       "expr"

Review comment:
       This seems less informative than it could be, what would you think of:
   ```r
     expect_output(
       record_batch(tbl) %>%
         filter(dbl > 2, chr == "d" | chr == "f") %>%
         select(chr, int, lgl) %>%
         filter(int < 5) %>%
         select(int, chr) %>%
         mutate(int2 = int * int, chr_rename = chr) %>%
         print(),
   'RecordBatch (query)
   int: int32 <- int
   chr: string <- chr
   int2: int32 <- multiply_checked(int, int)
   chr_rename: string <- chr
   
   * Filter: and(and(greater(dbl, 2), or(equal(chr, "d"), equal(chr, "f"))), 
less(int, 5))
   See $.data for the source Arrow object',
     fixed = TRUE
     )
   ```




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