jonkeane commented on code in PR #12818:
URL: https://github.com/apache/arrow/pull/12818#discussion_r845144322
##########
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:
_nods_ sorry I should have been a bit more specific — I didn't totally
follow what might cause the names of `new_col_names` to be empty (I imagine
that's what happens with any current columns at this point, given this
`ifelse()`: so here `cur_exprs` has names if it's a new column, but does not if
it doesn't, yeah?), but that isn't super super obvious on first read. And
actually, now that I'm looking at it, maybe the intention is to replace any
thing in `dots` that doesn't have a name with what's in `cur_expers`?
Would it be possible to do something like:
```
cur_exprs <- map_chr(dots, as_label)
transmute_order <- names(dots)
transmute_order[nzchar(transmute_order)] <-
cur_exprs[nzchar(transmute_order)]
```
or even something like `purrr::modify` or `purrr::modify_if`?
https://purrr.tidyverse.org/reference/modify.html
--
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]