~hrbrmstr/sergeant

ref: 1726a7c966b3bcaeee26a197eb1441c3884c079a sergeant/tests/testthat/test-dbi-internal.R -rw-r--r-- 1.3 KiB
1726a7c9hrbrmstr finalizing stuff for release 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
test_host <- Sys.getenv("DRILL_TEST_HOST", "localhost")

options(sergeant.bigint.warnonce = FALSE)

context("dbi")
test_that("core DBI ops work", {

  testthat::skip_on_cran()

  con <- dbConnect(Drill(), test_host)
  expect_is(con, "DrillConnection")

  expect_true(dbIsValid(con))

  fields <- dbListFields(con, "cp.`employee.json`")
  expect_true(
    all(
      fields %in%
        c(
          "employee_id", "full_name", "first_name", "last_name", "position_id",
          "position_title", "store_id", "department_id", "birth_date",
          "hire_date", "salary", "supervisor_id", "education_level", "marital_status",
          "gender", "management_role"
        )
    )
  )

  res <- dbSendQuery(con, "SELECT full_name from cp.`employee.json` LIMIT 1")
  expect_is(res, "DrillResult")

  xdf <- dbFetch(res)
  expect_identical(dim(xdf), c(1L, 1L))

  expect_true(dbClearResult(res))

  expect_true(dbHasCompleted(res))

  expect_equal(dbDataType(con, character(0)), "VARCHAR")
  expect_equal(dbDataType(con, integer(0)), "INTEGER")
  expect_equal(dbDataType(con, Sys.Date()), "DATE")
  expect_equal(dbDataType(con, Sys.time()), "TIMESTAMP")
  expect_equal(dbDataType(con, bit64::integer64(0)), "BIGINT")
  expect_equal(dbDataType(con, numeric(0)), "DOUBLE")

  expect_is(dbGetInfo(Drill()), "list")

  inf <- dbGetInfo(con)
  expect_equal(inf$port, 8047)

})