Skip to content

Commit

Permalink
ARROW-17673: [R] desc in dplyr::arrange should allow dplyr:: pr…
Browse files Browse the repository at this point in the history
…efix (apache#14090)

Authored-by: SHIMA Tatsuya <[email protected]>
Signed-off-by: Neal Richardson <[email protected]>
  • Loading branch information
eitsupi authored Sep 15, 2022
1 parent d8f64ee commit 5c773bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion r/R/dplyr-arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ find_and_remove_desc <- function(quosure) {
if (identical(expr[[1]], quote(`(`))) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
} else if (identical(expr[[1]], quote(desc)) || identical(expr[[1]], quote(dplyr::desc))) {
# ensure desc() has only one argument (when an R expression is a function
# call, length == 2 means it has exactly one argument)
if (length(expr) > 2) {
Expand Down
26 changes: 26 additions & 0 deletions r/tests/testthat/test-dplyr-arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,38 @@ test_that("arrange() on integer, double, and character columns", {
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int, dplyr::desc(dbl)) %>%
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int, desc(desc(dbl))) %>%
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int, dplyr::desc(dplyr::desc(dbl))) %>%
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int) %>%
arrange(desc(dbl)) %>%
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int) %>%
arrange(dplyr::desc(dbl)) %>%
collect(),
tbl
)
compare_dplyr_binding(
.input %>%
arrange(int + dbl, chr) %>%
Expand Down Expand Up @@ -200,6 +219,13 @@ test_that("arrange() with bad inputs", {
"expects only one argument",
fixed = TRUE
)
expect_error(
tbl %>%
Table$create() %>%
arrange(dplyr::desc(int, chr)),
"expects only one argument",
fixed = TRUE
)
})

test_that("Can use across() within arrange()", {
Expand Down

0 comments on commit 5c773bb

Please sign in to comment.