Skip to content

Commit

Permalink
Advance deprecation status
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Mar 15, 2024
1 parent 5355f88 commit 8313e1a
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 33 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# dbplyr (development version)

* Deprecation status of functions deprecated in previous versions (at least
2 years old) have been advanced. In particular, `src_sql()` is now defunct,
as is the use of `partial_eval()` with character `data`.

* `semi_join()` will no longer inline away an aggregate filter (i.e. `HAVING`
clause) that was followed by a `select()` (@ejneer, #1474)

Expand Down
2 changes: 1 addition & 1 deletion R/backend-teradata.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ utils::globalVariables(c("ATAN2", "SUBSTR", "DECIMAL", "WEEKNUMBER_OF_YEAR", "SU
#' @export
#' @rdname win_over
win_rank_tdata <- function(f) {
lifecycle::deprecate_soft(
lifecycle::deprecate_warn(
"2.4.0",
what = "win_rank_tdata()",
with = "win_rank()"
Expand Down
4 changes: 2 additions & 2 deletions R/db-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,9 @@ sql_query_append <- function(con,
...,
returning_cols = NULL) {
if (is_tbl_lazy(from)) {
lifecycle::deprecate_soft(
lifecycle::deprecate_warn(
when = "2.3.2",
what = "sql_query_append(from = 'must be a table identifier or an SQL query, not a lazy table.')",
what = "sql_query_append(from = 'must be a table identifier or an SQL query, not a lazy table.')"
)

insert_cols <- colnames(from)
Expand Down
4 changes: 1 addition & 3 deletions R/src-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
#' @param con the connection object
#' @param ... fields used by object
src_sql <- function(subclass, con, ...) {
lifecycle::deprecate_warn(
lifecycle::deprecate_stop(
when = "1.4.0",
what = "src_sql()",
always = TRUE
)
subclass <- paste0("src_", subclass)
structure(list(con = con, ...), class = c(subclass, "src_sql", "src"))
}


Expand Down
19 changes: 8 additions & 11 deletions R/tidyeval.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,16 @@
#' f <- function(x) x + 1
#' partial_eval(quote(year > f(1980)), lf)
#' partial_eval(quote(year > local(f(1980))), lf)
partial_eval <- function(call, data, env = caller_env(), vars = NULL, error_call) {
if (!is_null(vars)) {
lifecycle::deprecate_warn("2.1.2", "partial_eval(vars)", always = TRUE)
data <- lazy_frame(!!!rep_named(vars, list(logical())))
partial_eval <- function(call,
data,
env = caller_env(),
vars = deprecated(),
error_call) {
if (lifecycle::is_present(vars)) {
lifecycle::deprecate_stop("2.1.2", "partial_eval(vars)")
}

if (is.character(data)) {
lifecycle::deprecate_warn(
"2.1.2",
"partial_eval(data = 'must be a lazy frame')",
always = TRUE
)
data <- lazy_frame(!!!rep_named(data, list(logical())))
lifecycle::deprecate_stop("2.1.2", "partial_eval(data = 'must be a lazy frame')", )
}

if (is_sql_literal(call)) {
Expand Down
12 changes: 3 additions & 9 deletions R/verb-group_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@
#' group_by(g) %>%
#' mutate(x2 = x / sum(x, na.rm = TRUE)) %>%
#' show_query()
group_by.tbl_lazy <- function(.data, ..., .add = FALSE, add = NULL, .drop = TRUE) {
group_by.tbl_lazy <- function(.data, ..., .add = FALSE, add = deprecated(), .drop = TRUE) {
dots <- partial_eval_dots(.data, ..., .named = FALSE)

if (!missing(add)) {
lifecycle::deprecate_warn(
"1.0.0",
"dplyr::group_by(add = )",
"group_by(.add = )",
always = TRUE
)
.add <- add
if (lifecycle::is_present(add)) {
lifecycle::deprecate_stop("1.0.0", "dplyr::group_by(add)", "group_by(.add)")
}

check_unsupported_arg(.drop, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/verb-joins.R
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ join_prepare_by <- function(by,
user_env = caller_env(3)) {
if (identical(by, character()) && is.null(sql_on)) {
if (type != "cross") {
lifecycle::deprecate_soft(
lifecycle::deprecate_warn(
when = "1.1.0",
what = I("Using `by = character()` to perform a cross join"),
with = "cross_join()",
Expand Down
2 changes: 1 addition & 1 deletion man/group_by.tbl_lazy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/partial_eval.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/testthat/_snaps/tidyeval.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# old arguments are defunct

Code
partial_eval(quote(x), vars = c("x", "y"))
Condition
Error:
! The `vars` argument of `partial_eval()` was deprecated in dbplyr 2.1.2 and is now defunct.
Code
partial_eval(quote(x), data = c("x", "y"))
Condition
Error:
! The `data` argument of `partial_eval()` must be a lazy frame as of dbplyr 2.1.2.

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/verb-group_by.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# errors about add argument

Code
gf <- mf %>% group_by(x) %>% group_by(y, add = TRUE)
Condition
Error:
! The `add` argument of `group_by()` was deprecated in dplyr 1.0.0 and is now defunct.
i Please use the `.add` argument instead.

# errors for .drop = FALSE

Code
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-tidyeval.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ test_that("fails with multi-classes", {
x <- structure(list(), class = c('a', 'b'))
expect_error(partial_eval(x, lf), "Unknown input type", fixed = TRUE)
})

test_that("old arguments are defunct", {
expect_snapshot(error = TRUE, {
partial_eval(quote(x), vars = c("x", "y"))
partial_eval(quote(x), data = c("x", "y"))
})
})
7 changes: 3 additions & 4 deletions tests/testthat/test-verb-group_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ test_that("group_by with .add = TRUE adds groups", {
expect_equal(group_vars(gf2), c("x", "y"))
})

test_that("warns about add argument ", {
test_that("errors about add argument ", {
mf <- memdb_frame(x = 1:3, y = 1:3)
expect_warning(
expect_snapshot(
gf <- mf %>% group_by(x) %>% group_by(y, add = TRUE),
"deprecated"
error = TRUE
)
expect_equal(group_vars(gf), c("x", "y"))
})

test_that("errors for .drop = FALSE", {
Expand Down

0 comments on commit 8313e1a

Please sign in to comment.