ianmcook commented on a change in pull request #9745: URL: https://github.com/apache/arrow/pull/9745#discussion_r599912716
########## File path: r/R/dplyr.R ########## @@ -631,17 +669,98 @@ abandon_ship <- function(call, .data, msg = NULL) { eval.parent(call, 2) } -arrange.arrow_dplyr_query <- function(.data, ...) { +arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) { + # TODO: handle .by_group argument + if (!isFALSE(.by_group)) { + stop(".by_group argument not supported for Arrow objects", call. = FALSE) + } + + call <- match.call() + exprs <- quos(...) + + if (length(exprs) == 0) { + # Nothing to do + return(.data) + } + .data <- arrow_dplyr_query(.data) + + # Restrict the cases we support for now if (query_on_dataset(.data)) { not_implemented_for_dataset("arrange()") } - # TODO(ARROW-11703) move this to Arrow - call <- match.call() - abandon_ship(call, .data) + is_grouped <- length(dplyr::group_vars(.data)) > 0 + if (is_grouped) { + return(abandon_ship(call, .data, 'arrange() on grouped data not supported in Arrow')) + } + is_dataset <- query_on_dataset(.data) + if (is_dataset) { + return(abandon_ship(call, .data)) + } + + # find and remove any dplyr::desc() and tidy-eval + # the arrange expressions inside an Arrow data_mask + sorts <- vector("list", length(exprs)) + descs <- logical(0) + mask <- arrow_mask(.data) + for (i in seq_along(exprs)) { + x <- find_and_remove_desc(exprs[[i]]) + exprs[[i]] <- x[["quos"]] + sorts[[i]] <- arrow_eval(exprs[[i]], mask) Review comment: This is all wired up in 0ba20fb57c542e3099b047c792579819685c8888 -- 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