This is an automated email from the ASF dual-hosted git repository.

npr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 05b7fe35cf ARROW-17674: [R] Implement dplyr::across() inside arrange() 
(#14092)
05b7fe35cf is described below

commit 05b7fe35cf7c0dbba4d3c86882bb93560e606a13
Author: eitsupi <[email protected]>
AuthorDate: Tue Sep 13 00:16:13 2022 +0900

    ARROW-17674: [R] Implement dplyr::across() inside arrange() (#14092)
    
    Authored-by: SHIMA Tatsuya <[email protected]>
    Signed-off-by: Neal Richardson <[email protected]>
---
 r/R/dplyr-arrange.R                   |  3 ++-
 r/tests/testthat/test-dplyr-arrange.R | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/r/R/dplyr-arrange.R b/r/R/dplyr-arrange.R
index 247a539f52..2f9ef61bb3 100644
--- a/r/R/dplyr-arrange.R
+++ b/r/R/dplyr-arrange.R
@@ -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
diff --git a/r/tests/testthat/test-dplyr-arrange.R 
b/r/tests/testthat/test-dplyr-arrange.R
index fee1475a44..edec572d10 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
+  )
+})

Reply via email to