Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/testthat/_snaps/dplyr-case-match.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
case_match(1)
Condition
Error in `case_match()`:
! At least one condition must be supplied.
! `...` can't be empty.

---

Code
case_match(1, NULL)
Condition
Error in `case_match()`:
! At least one condition must be supplied.
! `...` can't be empty.

# `.default` is part of common type computation

Code
case_match(1, 1 ~ 1L, .default = "x")
Condition
Error in `case_match()`:
! Can't combine `..1 (right)` <integer> and `.default` <character>.
! Can't combine <integer> and `.default` <character>.

# `NULL` formula element throws meaningful error

Expand All @@ -29,6 +29,7 @@
Condition
Error in `case_match()`:
! `..1 (right)` must be a vector, not `NULL`.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

---

Expand All @@ -37,6 +38,7 @@
Condition
Error in `case_match()`:
! `..1 (left)` must be a vector, not `NULL`.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

# throws chained errors when formula evaluation fails

Expand Down
55 changes: 47 additions & 8 deletions tests/testthat/_snaps/dplyr-case-when.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
case_when(FALSE ~ 1L, .default = 2:5)
Condition
Error in `case_when()`:
! `.default` must have size 1, not size 4.
! Can't recycle `.default` (size 4) to size 1.

# `.default` is part of common type computation

Code
case_when(TRUE ~ 1L, .default = "x")
Condition
Error in `case_when()`:
! Can't combine `..1 (right)` <integer> and `.default` <character>.
! Can't combine <integer> and `.default` <character>.

# passes through `.size` correctly

Expand All @@ -35,8 +35,27 @@
Code
case_when(1 ~ NULL)
Condition
Error in `case_when()`:
! `..1 (right)` must be a vector, not `NULL`.
Warning:
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.

Please use a series of if statements instead:

```
# Previously
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)

# Now
if (scalar_lhs1) {
rhs1
} else if (scalar_lhs2) {
rhs2
} else {
default
}
```
Error in `case_when()`:
! `..1 (left)` must be a logical vector, not an empty numeric vector.

---

Expand Down Expand Up @@ -73,7 +92,7 @@
Output
<error/vctrs_error_incompatible_size>
Error in `case_when()`:
! Can't recycle `..1 (left)` (size 2) to match `..1 (right)` (size 3).
! Can't recycle `..1 (right)` (size 3) to match `..2 (right)` (size 2).
Code
(expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE,
TRUE, FALSE, NA) ~ 3)))
Expand All @@ -83,6 +102,26 @@
! Can't recycle `..1 (left)` (size 2) to match `..2 (left)` (size 3).
Code
(expect_error(case_when(50 ~ 1:3)))
Condition
Warning:
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.

Please use a series of if statements instead:

```
# Previously
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)

# Now
if (scalar_lhs1) {
rhs1
} else if (scalar_lhs2) {
rhs2
} else {
default
}
```
Output
<error/rlang_error>
Error in `case_when()`:
Expand All @@ -104,17 +143,17 @@
Output
<error/rlang_error>
Error in `case_when()`:
! At least one condition must be supplied.
! `...` can't be empty.
Code
(expect_error(case_when(NULL)))
Output
<error/rlang_error>
Error in `case_when()`:
! At least one condition must be supplied.
! `...` can't be empty.
Code
(expect_error(case_when(~ 1:2)))
Output
<error/rlang_error>
Error in `case_when()`:
! Case 1 (`~1:2`) must be a two-sided formula.
! Case 1 (`~1:2`) must be a two-sided formula, not a one-sided formula.

3 changes: 2 additions & 1 deletion tests/testthat/_snaps/dplyr-coalesce.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
coalesce(NULL, NULL)
Condition
Error in `coalesce()`:
! `...` can't be empty.
! `...` must contain at least 1 non-`NULL` value.

# inputs must be vectors

Expand All @@ -44,6 +44,7 @@
Condition
Error in `coalesce()`:
! `..2` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

# names in error messages are indexed correctly

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/_snaps/dplyr-consecutive-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
Condition
Error in `consecutive_id()`:
! `..1` must be a vector, not a function.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

34 changes: 4 additions & 30 deletions tests/testthat/_snaps/dplyr-count-tally.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@
Error in `count()`:
! `name` must be a single string, not a character vector.

# can only explicitly chain together multiple tallies

Code
df <- data.frame(g = c(1, 1, 2, 2), n = 1:4)
df %>% duckplyr_count(g, wt = n)
Output
g n
1 1 3
2 2 7
Code
df %>% duckplyr_count(g, wt = n) %>% duckplyr_count(wt = n)
Output
n
1 10
Code
df %>% duckplyr_count(n)
Message
Storing counts in `nn`, as `n` already present in input
i Use `name = "new_name"` to pick a new name.
Output
n nn
1 1 1
2 2 1
3 3 1
4 4 1

# duckplyr_count() owns errors (#6139)

Code
Expand All @@ -55,7 +29,7 @@
Output
<error/rlang_error>
Error in `summarise()`:
i In argument: `n = sum(1 + "", na.rm = TRUE)`.
i In argument: `n = base::sum(1 + "", na.rm = TRUE)`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator

Expand All @@ -66,7 +40,7 @@
Output
<error/rlang_error>
Error in `tally()`:
i In argument: `n = sum(1 + "", na.rm = TRUE)`.
i In argument: `n = base::sum(1 + "", na.rm = TRUE)`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator

Expand All @@ -85,7 +59,7 @@
Output
<error/dplyr:::mutate_error>
Error in `mutate()`:
i In argument: `n = sum(1 + "", na.rm = TRUE)`.
i In argument: `n = base::sum(1 + "", na.rm = TRUE)`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator

Expand All @@ -96,7 +70,7 @@
Output
<error/dplyr:::mutate_error>
Error in `add_tally()`:
i In argument: `n = sum(1 + "", na.rm = TRUE)`.
i In argument: `n = base::sum(1 + "", na.rm = TRUE)`.
Caused by error in `1 + ""`:
! non-numeric argument to binary operator

1 change: 1 addition & 0 deletions tests/testthat/_snaps/dplyr-desc.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
Condition
Error in `desc()`:
! `x` must be a vector, not a function.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

14 changes: 3 additions & 11 deletions tests/testthat/_snaps/dplyr-if-else.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@
if_else(x < 2, bad, x)
Condition
Error in `if_else()`:
! `true` must have size 3, not size 2.
! Can't recycle `true` (size 2) to size 3.

---

Code
if_else(x < 2, x, bad)
Condition
Error in `if_else()`:
! `false` must have size 3, not size 2.
! Can't recycle `false` (size 2) to size 3.

---

Code
if_else(x < 2, x, x, missing = bad)
Condition
Error in `if_else()`:
! `missing` must have size 3, not size 2.
! Can't recycle `missing` (size 2) to size 3.

# must have empty dots

Expand All @@ -66,11 +66,3 @@
! Can't convert from `false` <double> to <integer> due to loss of precision.
* Locations: 1

# `size` overrides the `condition` size

Code
if_else(TRUE, 1, 2, size = 2)
Condition
Error in `if_else()`:
! `condition` must have size 2, not size 1.

37 changes: 0 additions & 37 deletions tests/testthat/_snaps/dplyr-join-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,39 +319,11 @@
i 50000005000000 rows would be returned. 2147483647 rows is the maximum number allowed.
i Double check your join keys. This error commonly occurs due to a missing join key, or an improperly specified join condition.

# `multiple = NULL` is deprecated and results in `'all'` (#6731)

Code
out <- join_rows(df1, df2, multiple = NULL)
Condition
Warning:
Specifying `multiple = NULL` was deprecated in dplyr 1.1.1.
i Please use `multiple = "all"` instead.

---

Code
duckplyr_left_join(df1, df2, by = join_by(x), multiple = NULL)
Condition
Warning:
Specifying `multiple = NULL` was deprecated in dplyr 1.1.1.
i Please use `multiple = "all"` instead.
Output
# A tibble: 3 x 1
x
<dbl>
1 1
2 2
3 2

# `multiple = 'error'` is deprecated (#6731)

Code
join_rows(df1, df2, multiple = "error")
Condition
Warning:
Specifying `multiple = "error"` was deprecated in dplyr 1.1.1.
i Please use `relationship = "many-to-one"` instead.
Error:
! Each row in `x` must match at most 1 row in `y`.
i Row 2 of `x` matches multiple rows in `y`.
Expand All @@ -361,9 +333,6 @@
Code
duckplyr_left_join(df1, df2, by = join_by(x), multiple = "error")
Condition
Warning:
Specifying `multiple = "error"` was deprecated in dplyr 1.1.1.
i Please use `relationship = "many-to-one"` instead.
Error in `left_join()`:
! Each row in `x` must match at most 1 row in `y`.
i Row 2 of `x` matches multiple rows in `y`.
Expand All @@ -373,9 +342,6 @@
Code
out <- join_rows(df1, df2, multiple = "warning")
Condition
Warning:
Specifying `multiple = "warning"` was deprecated in dplyr 1.1.1.
i Please use `relationship = "many-to-one"` instead.
Warning:
Each row in `x` is expected to match at most 1 row in `y`.
i Row 2 of `x` matches multiple rows.
Expand All @@ -385,9 +351,6 @@
Code
duckplyr_left_join(df1, df2, by = join_by(x), multiple = "warning")
Condition
Warning:
Specifying `multiple = "warning"` was deprecated in dplyr 1.1.1.
i Please use `relationship = "many-to-one"` instead.
Warning in `left_join()`:
Each row in `x` is expected to match at most 1 row in `y`.
i Row 2 of `x` matches multiple rows.
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/dplyr-lead-lag.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
Condition
Error in `lead()`:
! `x` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

---

Expand All @@ -67,4 +68,5 @@
Condition
Error in `lag()`:
! `x` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

1 change: 1 addition & 0 deletions tests/testthat/_snaps/dplyr-n-distinct.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
Condition
Error in `n_distinct()`:
! `..1` must be a vector, not a function.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

2 changes: 2 additions & 0 deletions tests/testthat/_snaps/dplyr-na-if.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Condition
Error in `na_if()`:
! `x` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

---

Expand All @@ -46,4 +47,5 @@
Condition
Error in `na_if()`:
! `y` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

1 change: 1 addition & 0 deletions tests/testthat/_snaps/dplyr-nth-value.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
Condition
Error in `vec_size()`:
! `x` must be a vector, not an environment.
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.

# `order_by` must be the same size as `x`

Expand Down
Loading