Skip to content

Commit

Permalink
Merge pull request #166 from duckdblabs/f-dplyr-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed May 9, 2024
2 parents 5dcd60c + 3051eb4 commit 38927ee
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 45 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/across.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
Error in `summarise()`:
i In argument: `across(y, mean)`.
Caused by error in `across()`:
! Can't subset columns that don't exist.
! Can't select columns that don't exist.
x Column `y` doesn't exist.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = across(where(
Expand All @@ -97,7 +97,7 @@
Error in `summarise()`:
i In argument: `z = across(y, mean)`.
Caused by error in `across()`:
! Can't subset columns that don't exist.
! Can't select columns that don't exist.
x Column `y` doesn't exist.
Code
(expect_error(tibble(x = 1) %>% duckplyr_summarise(res = sum(if_any(where(
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/_snaps/join.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,31 @@
Error:
! `na_matches` must be one of "na" or "never", not "foo".

# mutating joins compute common columns

Code
out <- duckplyr_left_join(df1, df2)
Message
Joining with `by = join_by(x)`

# filtering joins compute common columns

Code
out <- duckplyr_semi_join(df1, df2)
Message
Joining with `by = join_by(x)`

# mutating joins reference original column in `y` when there are type errors (#6465)

Code
(expect_error(duckplyr_left_join(x, y, by = join_by(a == b))))
Output
<error/dplyr_error_join_incompatible_type>
Error in `left_join()`:
! Can't join `x$a` with `y$b` due to incompatible types.
i `x$a` is a <double>.
i `y$b` is a <character>.

# error if passed additional arguments

Code
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/_snaps/sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@
Output
Incompatible types for column `x`: double vs character.

# setequal tibbles must have same rows and columns

Code
duckplyr_setequal(tibble(x = 1:2), tibble(y = 1:2))
Condition
Error in `setequal()`:
! `x` and `y` are not compatible.
x Cols in `y` but not `x`: `y`.
x Cols in `x` but not `y`: `x`.

---

Code
duckplyr_setequal(tibble(x = 1:2), tibble(x = c("a", "b")))
Condition
Error in `setequal()`:
! `x` and `y` are not compatible.
x Incompatible types for column `x`: integer vs character.

# setequal checks for extra arguments

Code
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-across.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ test_that("across() throws meaningful error with failure during expansion (#6534
})

test_that("across() gives meaningful messages", {
skip("TODO duckdb")
skip_if(Sys.getenv("DUCKPLYR_FORCE") == "TRUE")
expect_snapshot({
# expanding
Expand Down Expand Up @@ -599,7 +598,6 @@ test_that("across() caching not confused when used from if_any() and if_all() (#
})

test_that("if_any() and if_all() respect duckplyr_filter()-like NA handling", {
skip("TODO duckdb")
df <- expand.grid(
x = c(TRUE, FALSE, NA), y = c(TRUE, FALSE, NA)
)
Expand Down Expand Up @@ -953,7 +951,6 @@ test_that("if_any() and if_all() wrapped deal with no inputs or single inputs",
})

test_that("expanded if_any() finds local data", {
skip("TODO duckdb")
limit <- 7
df <- data.frame(x = 1:10, y = 10:1)

Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-deprec-do.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ test_that("grouped do evaluates args in correct environment", {
# Ungrouped data frames --------------------------------------------------------

test_that("ungrouped data frame with unnamed argument returns data frame", {
skip("TODO duckdb")
out <- mtcars %>% duckplyr_do(head(.))
expect_s3_class(out, "data.frame")
expect_equal(dim(out), c(6, 11))
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ test_that("date class remains on filter (#273)", {
})

test_that("filter handles $ correctly (#278)", {
skip("TODO duckdb")
d1 <- tibble(
num1 = as.character(sample(1:10, 1000, T)),
var1 = runif(1000),
Expand Down Expand Up @@ -596,7 +595,6 @@ test_that("duckplyr_filter() preserves the call stack on error (#5308)", {
})

test_that("if_any() and if_all() work", {
skip("TODO duckdb")
df <- tibble(x1 = 1:10, x2 = c(1:5, 10:6))
expect_equal(
duckplyr_filter(df, if_all(starts_with("x"), ~ . > 6)),
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-group-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ test_that("duckplyr_group_map() can return arbitrary objects", {
})

test_that("duckplyr_group_map() works on ungrouped data frames (#4067)", {
skip("TODO duckdb")
expect_identical(
duckplyr_group_map(mtcars, ~ head(.x, 2L)),
list(head(as_tibble(mtcars), 2L))
Expand Down Expand Up @@ -62,7 +61,6 @@ test_that("duckplyr_group_modify() and duckplyr_group_map() want functions with
})

test_that("duckplyr_group_modify() works on ungrouped data frames (#4067)", {
skip("TODO duckdb")
expect_identical(
duckplyr_group_modify(mtcars, ~ head(.x, 2L)),
head(mtcars, 2L)
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-join.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ test_that("keys are coerced to symmetric type", {
})

test_that("factor keys are coerced to the union factor type", {
skip("TODO duckdb")
df1 <- tibble(x = 1, y = factor("a"))
df2 <- tibble(x = 2, y = factor("b"))
out <- duckplyr_full_join(df1, df2, by = c("x", "y"))
Expand Down Expand Up @@ -417,7 +416,6 @@ test_that("mutating joins finalize unspecified columns (#6804)", {
})

test_that("filtering joins finalize unspecified columns (#6804)", {
skip("TODO duckdb")
df1 <- tibble(x = NA)
df2 <- tibble(x = NA)

Expand All @@ -443,7 +441,6 @@ test_that("filtering joins finalize unspecified columns (#6804)", {
})

test_that("mutating joins reference original column in `y` when there are type errors (#6465)", {
skip("TODO duckdb")
x <- tibble(a = 1)
y <- tibble(b = "1")

Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-mutate.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ test_that("can mutate a data frame with zero columns", {
})

test_that("duckplyr_mutate() handles symbol expressions", {
skip("TODO duckdb")
df <- tibble(x = structure(1, class = "alien"))
res <- duckplyr_mutate(df, y = x)
expect_identical(df$x, res$y)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-sets.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ test_that("setequal uses coercion rules (#6114)", {
})

test_that("setequal tibbles must have same rows and columns", {
skip("TODO duckdb")
# Different rows are the definition of not equal
expect_false(duckplyr_setequal(tibble(x = 1:2), tibble(x = 2:3)))

Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-summarise.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ test_that("assigning with `<-` doesn't affect the mask (#6666)", {
})

test_that("duckplyr_summarise() correctly auto-names expressions (#6741)", {
skip("TODO duckdb")
df <- tibble(a = 1:3)
expect_identical(duckplyr_summarise(df, min(-a)), tibble("min(-a)" = -3L))
})
Expand Down
31 changes: 2 additions & 29 deletions tools/00-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ duckplyr_tests <- head(n = -1, list(
NULL
),
"test-across.R" = c(
# Sort order
"if_any() and if_all() respect filter()-like NA handling",
"expanded if_any() finds local data",
# needs tidyselect > 1.2.0 for stable snapshots
"across() gives meaningful messages",
NULL
),
"test-all-equal.R" = c(
Expand All @@ -91,7 +86,6 @@ duckplyr_tests <- head(n = -1, list(
NULL
),
"test-deprec-do.R" = c(
"ungrouped data frame with unnamed argument returns data frame",
NULL
),
"test-deprec-funs.R" = c(
Expand All @@ -101,21 +95,14 @@ duckplyr_tests <- head(n = -1, list(
NULL
),
"test-filter.R" = c(
# FIXME: oo for filter?
"if_any() and if_all() work",

# FIXME: oo for %in%
"filter handles $ correctly (#278)",
NULL
),
"test-generics.R" = c(
# https://github.com/tidyverse/dplyr/pull/7022
"`dplyr_reconstruct()`, which gets and sets attributes, doesn't touch `row.names` (#6525)",

NULL
),
"test-group-map.R" = c(
"duckplyr_group_map() works on ungrouped data frames (#4067)",
"group_modify() works on ungrouped data frames (#4067)",
NULL
),
"test-groups-with.R" = c(
Expand All @@ -125,18 +112,11 @@ duckplyr_tests <- head(n = -1, list(
"mutating joins trigger multiple match warning",
"mutating joins don't trigger multiple match warning when called indirectly",

"mutating joins reference original column in `y` when there are type errors (#6465)",
"filtering joins reference original column in `y` when there are type errors (#6465)",

"mutating joins trigger many-to-many warning",
"mutating joins compute common columns",
"mutating joins don't trigger many-to-many warning when called indirectly",

# https://github.com/duckdb/duckdb/issues/7451
# https://github.com/tidyverse/dplyr/pull/6846
"factor keys are coerced to the union factor type",

"filtering joins finalize unspecified columns (#6804)",
NULL
),
"test-join-rows.R" = c(
Expand All @@ -147,8 +127,6 @@ duckplyr_tests <- head(n = -1, list(
NULL
),
"test-mutate.R" = c(
# FIXME: vector class?
"mutate() handles symbol expressions",
NULL
),
"test-pull.R" = c(
Expand All @@ -164,20 +142,15 @@ duckplyr_tests <- head(n = -1, list(
NULL
),
"test-sets.R" = c(
"setequal tibbles must have same rows and columns",

NULL
),
"test-slice.R" = c(
NULL
),
"test-summarise.R" = c(
# Removed sum() macro for now
# Will be fixed by extension
"works with empty data frames",

# sum(1:3) returns HUGEINT in duckdb
"summarise() correctly auto-names expressions (#6741)",

# Fails in R CMD check
"summarise() gives meaningful errors",

Expand Down

0 comments on commit 38927ee

Please sign in to comment.