From 6651b75f711a1fef3ccf3a263849e8225c10cb9a Mon Sep 17 00:00:00 2001 From: SHIMA Tatsuya Date: Sat, 10 Sep 2022 14:02:26 +0000 Subject: [PATCH 1/3] Implement dplyr::across() inside arrange() Signed-off-by: SHIMA Tatsuya --- r/R/dplyr-arrange.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/r/R/dplyr-arrange.R b/r/R/dplyr-arrange.R index 247a539f527..85cddade531 100644 --- a/r/R/dplyr-arrange.R +++ b/r/R/dplyr-arrange.R @@ -20,7 +20,10 @@ arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) { call <- match.call() - exprs <- quos(...) + + expression_list <- expand_across(.data, quos(...)) + exprs <- ensure_named_exprs(expression_list) + if (.by_group) { # when the data is is grouped and .by_group is TRUE, order the result by # the grouping columns first From 3667337011979c84ebcb2c1e48dfa9d721459f9c Mon Sep 17 00:00:00 2001 From: SHIMA Tatsuya Date: Sat, 10 Sep 2022 14:15:35 +0000 Subject: [PATCH 2/3] add tests Signed-off-by: SHIMA Tatsuya --- r/tests/testthat/test-dplyr-arrange.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/r/tests/testthat/test-dplyr-arrange.R b/r/tests/testthat/test-dplyr-arrange.R index fee1475a44e..edec572d10f 100644 --- a/r/tests/testthat/test-dplyr-arrange.R +++ b/r/tests/testthat/test-dplyr-arrange.R @@ -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 + ) +}) From 0cf7585f704b1a719ced30001d10bd0021200ef5 Mon Sep 17 00:00:00 2001 From: SHIMA Tatsuya Date: Mon, 12 Sep 2022 14:08:49 +0000 Subject: [PATCH 3/3] remove unused lines Signed-off-by: SHIMA Tatsuya --- r/R/dplyr-arrange.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/r/R/dplyr-arrange.R b/r/R/dplyr-arrange.R index 85cddade531..2f9ef61bb31 100644 --- a/r/R/dplyr-arrange.R +++ b/r/R/dplyr-arrange.R @@ -20,9 +20,7 @@ arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) { call <- match.call() - - expression_list <- expand_across(.data, quos(...)) - exprs <- ensure_named_exprs(expression_list) + exprs <- expand_across(.data, quos(...)) if (.by_group) { # when the data is is grouped and .by_group is TRUE, order the result by