thisisnic commented on code in PR #13786:
URL: https://github.com/apache/arrow/pull/13786#discussion_r945814037
##########
r/R/dplyr-mutate.R:
##########
@@ -151,3 +153,95 @@ ensure_named_exprs <- function(exprs) {
names(exprs)[unnamed] <- map_chr(exprs[unnamed], format_expr)
exprs
}
+
+# Take the input quos and unfold any instances of across()
+# into individual quosures
+unfold_across <- function(.data, quos_in) {
+ quos_out <- list()
+ # Check for any expressions starting with across
+ for (quo_i in seq_along(quos_in)) {
+ quo_in <- quos_in[quo_i]
+ quo_expr <- quo_get_expr(quo_in[[1]])
+ quo_env <- quo_get_env(quo_in[[1]])
+
+ if (is_call(quo_expr, "across")) {
+ new_quos <- list()
+ across_call <- call_match(quo_expr, dplyr::across, defaults = TRUE)
+
+ if (!all(names(across_call[-1]) %in% c(".cols", ".fns", ".names"))) {
+ abort("`...` argument to `across()` is deprecated in dplyr and not
supported in Arrow")
+ }
+
+ # ARROW-17364: add support for .names argument
+ if (!is.null(across_call[[".names"]])) {
+ abort("`.names` argument to `across()` not yet supported in Arrow")
+ }
+
+ # use select() to get the columns so we can take advantage of tidyselect
+ source_cols <- names(dplyr::select(.data, !!across_call[[".cols"]]))
+ funcs <- across_call[[".fns"]]
+
+ # calling across() with .fns = NULL returns all columns unchanged
+ if (is_empty(funcs)) {
+ return()
+ }
+
+ if (!is_list(funcs) && as.character(funcs)[[1]] == "~") {
+ abort(
+ paste(
+ "purrr-style lambda functions as `.fns` argument to `across()`",
Review Comment:
I don't think that works; `as_mapper()` get us the function, but what I want
is the name of the function so that I can make a quosure, which later turns
into something which a later step turns into something that Arrow can work with.
--
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]