tests/testthat/test-integer64.R

# this tests both retrieval and scans
test_that("we can roundtrip an integer64 via driver", {
  skip_if_not_installed("bit64")
  con <- dbConnect(duckdb(bigint = "integer64"))
  on.exit(dbDisconnect(con, shutdown = TRUE))
  df <- data.frame(a = bit64::as.integer64(42), b = bit64::as.integer64(-42), c = bit64::as.integer64(NA))

  duckdb_register(con, "df", df)

  res <- dbReadTable(con, "df")
  expect_identical(df, res)
})

test_that("we can roundtrip an integer64 via dbConnect", {
  skip_if_not_installed("bit64")
  con <- dbConnect(duckdb(), bigint = "integer64")
  on.exit(dbDisconnect(con, shutdown = TRUE))
  df <- data.frame(a = bit64::as.integer64(42), b = bit64::as.integer64(-42), c = bit64::as.integer64(NA))

  duckdb_register(con, "df", df)

  res <- dbReadTable(con, "df")
  expect_identical(df, res)
})

Try the duckdb package in your browser

Any scripts or data that you put into this service are public.

duckdb documentation built on Oct. 30, 2024, 5:06 p.m.