Skip to content

Commit

Permalink
ARROW-17674: [R] Implement dplyr::across() inside arrange() (apache#1…
Browse files Browse the repository at this point in the history
…4092)

Authored-by: SHIMA Tatsuya <[email protected]>
Signed-off-by: Neal Richardson <[email protected]>
  • Loading branch information
eitsupi authored and fatemehp committed Oct 17, 2022
1 parent 93de2b5 commit 5fa8ef1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion r/R/dplyr-arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) {
call <- match.call()
exprs <- quos(...)
exprs <- expand_across(.data, quos(...))

if (.by_group) {
# when the data is is grouped and .by_group is TRUE, order the result by
# the grouping columns first
Expand Down
15 changes: 15 additions & 0 deletions r/tests/testthat/test-dplyr-arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,18 @@ test_that("arrange() with bad inputs", {
fixed = TRUE
)
})

test_that("Can use across() within arrange()", {
compare_dplyr_binding(
.input %>%
arrange(across(starts_with("d"))) %>%
collect(),
example_data
)
compare_dplyr_binding(
.input %>%
arrange(across(starts_with("d"), desc)) %>%
collect(),
example_data
)
})

0 comments on commit 5fa8ef1

Please sign in to comment.