paleolimbot commented on code in PR #13786: URL: https://github.com/apache/arrow/pull/13786#discussion_r959554332
########## r/tests/testthat/test-dplyr-mutate.R: ########## @@ -589,3 +588,106 @@ test_that("mutate() and transmute() with namespaced functions", { tbl ) }) + +test_that("Can use across() within mutate()", { + compare_dplyr_binding( + .input %>% + mutate(across(c(dbl, dbl2), round)) %>% + collect(), + tbl + ) + + compare_dplyr_binding( + .input %>% + mutate(across(c(dbl, dbl2), list(exp, sqrt))) %>% + collect(), + tbl + ) + + # across() arguments not in default order + compare_dplyr_binding( + .input %>% + mutate(across(.fns = round, c(dbl, dbl2))) %>% + collect(), + tbl + ) + + # ARROW-17364: .names argument not yet supported for across() + expect_error( + tbl %>% + arrow_table() %>% + mutate(across(c(dbl, dbl2), round, .names = "{.col}.{.fn}")) %>% + collect(), + regexp = "`.names` argument to `across()` not yet supported in Arrow", + fixed = TRUE + ) + + # ellipses (...) are a deprecated argument + expect_error( + tbl %>% + arrow_table() %>% + mutate(across(c(dbl, dbl2), round, digits = -1)) %>% + collect(), + regexp = "`...` argument to `across()` is deprecated in dplyr and not supported in Arrow", + fixed = TRUE + ) + + # alternative ways of specifying .fns - as a list + compare_dplyr_binding( + .input %>% + mutate(across(1:dbl2, list(round))) %>% + collect(), + tbl + ) + Review Comment: Sorry for missing this comment...I think it's a good test to have in there because you're walking the syntax tree yourself. When I wrote this, I was worried somebody would get something like `object of type LANGSXP is not subsettable` or something. -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org