Skip to content

Commit

Permalink
Bump dbplyr required version
Browse files Browse the repository at this point in the history
And remove conditionals (including an old one for dplyr)
  • Loading branch information
hadley committed May 15, 2020
1 parent bab0375 commit 9012dd0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Imports:
Suggests:
covr,
DBItest,
dbplyr,
dbplyr (>= 1.3.0),
dplyr (>= 0.7.0),
hms,
readr,
Expand Down
3 changes: 0 additions & 3 deletions R/dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ src_bigquery <- function(project, dataset, billing = project, max_pages = 10) {
if (!requireNamespace("dplyr", quietly = TRUE)) {
stop("dplyr is required to use src_bigquery", call. = FALSE)
}
if (utils::packageVersion("dplyr") < "0.6.0") {
stop("dplyr 0.6.0 and dbplyr required to use src_bigquery", call. = FALSE)
}

con <- DBI::dbConnect(
bigquery(),
Expand Down
16 changes: 3 additions & 13 deletions tests/testthat/test-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ test_that("collect can identify directly download tables", {
bq3 <- dplyr::filter(bq1, cyl == 1)
expect_false(op_can_download(bq3$ops))

skip_if_not_installed("dbplyr", "1.2.1.9001")
x <- dplyr::collect(bq1)
expect_s3_class(x, "tbl")
})
Expand All @@ -127,13 +126,8 @@ test_that("casting uses bigquery types", {
dplyr::mutate(y = as.integer(x), z = as.numeric(x)) %>%
dbplyr::sql_build(simulate_bigrquery())

if (utils::packageVersion("dbplyr") > "1.3.0") {
expect_equal(sql$select[[2]], 'SAFE_CAST(`x` AS INT64)')
expect_equal(sql$select[[3]], 'SAFE_CAST(`x` AS FLOAT64)')
} else {
expect_equal(sql$select[[2]], 'SAFE_CAST(`x` AS INT64) AS `y`')
expect_equal(sql$select[[3]], 'SAFE_CAST(`x` AS FLOAT64) AS `z`')
}
expect_equal(sql$select[[2]], 'SAFE_CAST(`x` AS INT64)')
expect_equal(sql$select[[3]], 'SAFE_CAST(`x` AS FLOAT64)')
})

test_that("%||% translates to IFNULL", {
Expand All @@ -143,9 +137,5 @@ test_that("%||% translates to IFNULL", {
dplyr::mutate(y = x %||% 2L) %>%
dbplyr::sql_build(simulate_bigrquery())

if (utils::packageVersion("dbplyr") > "1.3.0") {
expect_equal(sql$select[[2]], 'IFNULL(`x`, 2)')
} else {
expect_equal(sql$select[[2]], 'IFNULL(`x`, 2) AS `y`')
}
expect_equal(sql$select[[2]], 'IFNULL(`x`, 2)')
})

0 comments on commit 9012dd0

Please sign in to comment.