diff --git a/tests/testthat/_snaps/verb-select.md b/tests/testthat/_snaps/verb-select.md index 8046580bd..0140cc721 100644 --- a/tests/testthat/_snaps/verb-select.md +++ b/tests/testthat/_snaps/verb-select.md @@ -181,22 +181,6 @@ Error in `select()`: ! This tidyselect interface doesn't support predicates. -# computed columns are not inlined away - - Code - lf %>% mutate(z = 1) %>% arrange(x, z) %>% select(x) - Condition - Warning: - ORDER BY is ignored in subqueries without LIMIT - i Do you need to move arrange() later in the pipeline or use window_order() instead? - Output - - SELECT `x` - FROM ( - SELECT `df`.*, 1.0 AS `z` - FROM `df` - ) AS `q01` - # multiple selects are collapsed Code diff --git a/tests/testthat/test-verb-select.R b/tests/testthat/test-verb-select.R index f0fb8d48b..8064839c1 100644 --- a/tests/testthat/test-verb-select.R +++ b/tests/testthat/test-verb-select.R @@ -284,12 +284,28 @@ test_that("where() isn't suppored", { }) }) -test_that("computed columns are not inlined away", { - lf <- lazy_frame(x = 1, y = 2) +test_that("arranged computed columns are not inlined away", { + lf <- lazy_frame(x = 1) - expect_snapshot({ - lf %>% mutate(z = 1) %>% arrange(x, z) %>% select(x) - }) + # shouldn't inline + out <- lf %>% mutate(z = 2) %>% arrange(x, z) %>% select(x) + # should inline + out2 <- lf %>% mutate(z = 2) %>% arrange(x, z) %>% select(x, z) + + inner_query <- out$lazy_query$x + expect_s3_class(inner_query, "lazy_select_query") + expect_equal( + inner_query$order_by, + list(quo(x), quo(z)), + ignore_formula_env = TRUE + ) + expect_equal(op_vars(inner_query), c("x", "z")) + expect_equal(op_vars(out$lazy_query), "x") + expect_equal( + # order vars in a subquery are dropped + inner_query[setdiff(names(inner_query), "order_vars")], + out2$lazy_query[setdiff(names(out2$lazy_query), "order_vars")] + ) }) # sql_render --------------------------------------------------------------