ianmcook commented on a change in pull request #9999:
URL: https://github.com/apache/arrow/pull/9999#discussion_r626901825
##########
File path: r/tests/testthat/test-dplyr-mutate.R
##########
@@ -32,59 +51,23 @@ test_that("mutate() is lazy", {
)
})
-test_that("basic mutate", {
- expect_dplyr_equal(
- input %>%
- select(int, chr) %>%
- filter(int > 5) %>%
- mutate(int = int + 6L) %>%
- collect(),
- tbl
- )
-})
+# similar to
https://github.com/tidyverse/dplyr/blob/master/tests/testthat/test-mutate.r#L1-L10
+test_that("empty mutate returns input", {
+ # dbl2 = 5, so I'm grouping by a constant
+ gtbl <- group_by(tbl, dbl2)
-test_that("mutate() with NULL inputs", {
- expect_dplyr_equal(
- input %>%
- mutate(int = NULL) %>%
- collect(),
- tbl
- )
+ expect_dplyr_equal(input %>% mutate() %>% collect(), tbl)
+ expect_dplyr_equal(input %>% mutate(!!!list()) %>% collect(), tbl)
+ expect_dplyr_equal(input %>% mutate() %>% collect(), gtbl)
+ expect_dplyr_equal(input %>% mutate(!!!list()) %>% collect(), gtbl)
Review comment:
The intent is to check that `mutate()` returns its input regardless of
whether its input is grouped. @pachamaltese could you please add a concise
comment saying that?
Also: because of ARROW-11769, the grouping added to `gtbl` by `group_by()`
is actually lost when it's converted to a `Table` or `RecordBatch`. The tests
pass regardless of this because `expect_dplyr_equal()` calls
`expect_equivalent()` which ignores grouping. But we should fix it regardless.
To do this, remove the `gtbl` assignment above and rewrite the two tests
involving `gtbl` like this:
```r
expect_dplyr_equal(input %>% group_by(dbl2) %>% mutate() %>% collect())
expect_dplyr_equal(input %>% group_by(dbl2) %>% mutate(!!!list()) %>%
collect())
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]