diff --git a/R/backend-dbplyr__duckdb_connection.R b/R/backend-dbplyr__duckdb_connection.R index 4dda1aa96..c27f03f6f 100644 --- a/R/backend-dbplyr__duckdb_connection.R +++ b/R/backend-dbplyr__duckdb_connection.R @@ -7,7 +7,7 @@ #' #' @name backend-duckdb #' @aliases NULL -#' @examples +#' @examplesIf rlang::is_installed("dbplyr") #' library(dplyr, warn.conflicts = FALSE) #' con <- DBI::dbConnect(duckdb(), path = ":memory:") #' diff --git a/man/backend-duckdb.Rd b/man/backend-duckdb.Rd index cdac292c0..3eab99358 100644 --- a/man/backend-duckdb.Rd +++ b/man/backend-duckdb.Rd @@ -18,6 +18,7 @@ possibilities. This mainly follows the backend for PostgreSQL, but contains more mapped functions. } \examples{ +\dontshow{if (rlang::is_installed("dbplyr")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(dplyr, warn.conflicts = FALSE) con <- DBI::dbConnect(duckdb(), path = ":memory:") @@ -29,4 +30,5 @@ dbiris \%>\% head(5) DBI::dbDisconnect(con, shutdown = TRUE) +\dontshow{\}) # examplesIf} } diff --git a/tests/testthat/test_arrow_stream.R b/tests/testthat/test_arrow_stream.R index f16f5ce2d..966a7c3b4 100644 --- a/tests/testthat/test_arrow_stream.R +++ b/tests/testthat/test_arrow_stream.R @@ -1,6 +1,7 @@ skip_on_cran() skip_on_os("windows") skip_if_not_installed("arrow", "5.0.0") +skip_if_not_installed("dbplyr") library("testthat") library("DBI") diff --git a/tests/testthat/test_tbl__duckdb_connection.R b/tests/testthat/test_tbl__duckdb_connection.R index f0bb07d82..3b3fbea01 100644 --- a/tests/testthat/test_tbl__duckdb_connection.R +++ b/tests/testthat/test_tbl__duckdb_connection.R @@ -1,7 +1,11 @@ skip_on_cran() -`%>%` <- dplyr::`%>%` +if (rlang::is_installed("dbplyr")) { + `%>%` <- dplyr::`%>%` +} test_that("Parquet files can be registered with dplyr::tbl()", { + skip_if_not_installed("dbplyr") + con <- DBI::dbConnect(duckdb()) on.exit(DBI::dbDisconnect(con, shutdown = TRUE)) @@ -24,6 +28,8 @@ test_that("Parquet files can be registered with dplyr::tbl()", { test_that("Object cache can be enabled for parquet files with dplyr::tbl()", { + skip_if_not_installed("dbplyr") + con <- DBI::dbConnect(duckdb()) on.exit(DBI::dbDisconnect(con, shutdown = TRUE)) @@ -38,6 +44,8 @@ test_that("Object cache can be enabled for parquet files with dplyr::tbl()", { test_that("CSV files can be registered with dplyr::tbl()", { + skip_if_not_installed("dbplyr") + path <- file.path(tempdir(), "duckdbtest.csv") write.csv(iris, file = path) on.exit(unlink(path)) @@ -55,6 +63,8 @@ test_that("CSV files can be registered with dplyr::tbl()", { }) test_that("Other replacement scans or functions can be registered with dplyr::tbl()", { + skip_if_not_installed("dbplyr") + con <- DBI::dbConnect(duckdb()) on.exit(DBI::dbDisconnect(con, shutdown = TRUE)) @@ -64,12 +74,14 @@ test_that("Other replacement scans or functions can be registered with dplyr::tb }) test_that("Strings tagged as SQL will be handled correctly with dplyr::tbl()", { + skip_if_not_installed("dbplyr") + con <- DBI::dbConnect(duckdb()) on.exit(DBI::dbDisconnect(con, shutdown = TRUE)) - + rs <- dplyr::tbl(con, dplyr::sql("SELECT 1")) expect_true(inherits(rs, "tbl_duckdb_connection")) expect_true(rs %>% dplyr::collect() == 1) }) -rm(`%>%`) +try(rm(`%>%`))