Skip to content

Commit

Permalink
Add dbDataType example on data frame to documentation and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodmeng committed Nov 10, 2022
1 parent 0de8a2b commit ccd9c89
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/dbDataType.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ get_vector_type <- function(obj) {
#' c(as.Date("2016-03-01"), as.Date("2016-03-02"))
#' )
#' )
#' dbDataType(drv, iris)
#' @importMethodsFrom DBI dbDataType
#' @export
setMethod("dbDataType", "PrestoDriver", .dbDataType)
1 change: 1 addition & 0 deletions man/dbDataType.Rd

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

16 changes: 16 additions & 0 deletions tests/testthat/test-dbDataType.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

context("dbDataType")

source("utilities.R")

with_locale(test.locale(), test_that)("presto simple types are correct", {
drv <- RPresto::Presto()

Expand All @@ -24,6 +26,20 @@ with_locale(test.locale(), test_that)("presto simple types are correct", {
)
expect_equal(dbDataType(drv, factor()), "VARCHAR")
expect_equal(dbDataType(drv, factor(ordered = TRUE)), "VARCHAR")
expect_equal(
dbDataType(drv, test_df),
c(
field1 = "VARCHAR",
field2 = "INTEGER",
field3 = "DOUBLE",
field4 = "BOOLEAN",
field5 = "DATE",
field6 = "TIMESTAMP",
field7 = "TIME",
field8 = "ARRAY<INTEGER>",
field9 = "ARRAY<DOUBLE>"
)
)
})

test_that("conversion to array is correct", {
Expand Down

0 comments on commit ccd9c89

Please sign in to comment.