boshek commented on code in PR #12818:
URL: https://github.com/apache/arrow/pull/12818#discussion_r845302595
##########
r/R/dplyr-mutate.R:
##########
@@ -112,7 +113,15 @@ mutate.Dataset <- mutate.ArrowTabular <-
mutate.RecordBatchReader <- mutate.arro
transmute.arrow_dplyr_query <- function(.data, ...) {
dots <- check_transmute_args(...)
- dplyr::mutate(.data, !!!dots, .keep = "none")
+ has_null <- vapply(dots, quo_is_null, logical(1))
+ .data <- dplyr::mutate(.data, !!!dots, .keep = "none")
+ if (is_empty(dots) | any(has_null)) return(.data)
+
+ ## keeping with: https://github.com/tidyverse/dplyr/issues/6086
+ cur_exprs <- vapply(dots, as_label, character(1))
+ new_col_names <- names(dots)
+ transmute_order <- ifelse(nzchar(new_col_names), new_col_names, cur_exprs)
Review Comment:
> maybe the intention is to replace any thing in dots that doesn't have a
name with what's in cur_expers
Yes you are exactly right. I just realized that because `map_chr` returns a
named vector I can equally get the names from `names(cur_exprs)`. Also
`coalesce` might work here too. What about this?
```r
cur_exprs <- map_chr(dots, as_label)
transmute_order <- dplyr::coalesce(na_if(names(cur_exprs), ""), cur_exprs)
```
--
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]