File: test-backend-impala.R

package info (click to toggle)
r-cran-dbplyr 2.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,376 kB
  • sloc: sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
test_that("custom scalar functions translated correctly", {
  local_con(simulate_impala())

  expect_equal(translate_sql(as.Date(x)), sql("CAST(`x` AS VARCHAR(10))"))
  expect_equal(translate_sql(ceiling(x)), sql("CEIL(`x`)"))
})

test_that("custom bitwise operations translated correctly", {
  local_con(simulate_impala())

  expect_equal(translate_sql(bitwNot(x)),        sql("BITNOT(`x`)"))
  expect_equal(translate_sql(bitwAnd(x, 128L)),  sql("BITAND(`x`, 128)"))
  expect_equal(translate_sql(bitwOr(x, 128L)),   sql("BITOR(`x`, 128)"))
  expect_equal(translate_sql(bitwXor(x, 128L)),  sql("BITXOR(`x`, 128)"))
  expect_equal(translate_sql(bitwShiftL(x, 2L)), sql("SHIFTLEFT(`x`, 2)"))
  expect_equal(translate_sql(bitwShiftR(x, 2L)), sql("SHIFTRIGHT(`x`, 2)"))
})

test_that("generates custom sql", {
  con <- simulate_impala()

  expect_snapshot(sql_table_analyze(con, in_schema("schema", "tbl")))
})