jonkeane commented on code in PR #12818:
URL: https://github.com/apache/arrow/pull/12818#discussion_r845378529


##########
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:
   `dplyr::coalesce` works here (and since this is a dplyr function, we can be 
pretty sure dplyr is already installed), but generally we try to shy away from 
using dplyr as a dependency. 
   
   So I would say let's get the names from `cur_exprs` but then do the more 
base `transmute_order[is.na(names(...))] <- ...` assignment style. IMO it also 
is slightly more explicit about what we're doing (replacing anything that 
doesn't have a name with a name-like representation of itself)



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

Reply via email to