Skip to content

Commit

Permalink
Merge pull request #29 from duckdb/b-dplyr
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Oct 16, 2023
2 parents d243b53 + c05bbf5 commit b2b10f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/backend-dbplyr__duckdb_connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
#'
Expand Down
2 changes: 2 additions & 0 deletions man/backend-duckdb.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test_arrow_stream.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
18 changes: 15 additions & 3 deletions tests/testthat/test_tbl__duckdb_connection.R
Original file line number Diff line number Diff line change
@@ -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))

Expand All @@ -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))

Expand All @@ -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))
Expand All @@ -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))

Expand All @@ -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(`%>%`))

0 comments on commit b2b10f1

Please sign in to comment.