File: test-backend-odbc.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 (26 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (2)
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
test_that("custom scalar translated correctly", {
  local_con(simulate_odbc())

  expect_equal(translate_sql(as.numeric(x)),            sql("CAST(`x` AS DOUBLE)"))
  expect_equal(translate_sql(as.double(x)),             sql("CAST(`x` AS DOUBLE)"))
  expect_equal(translate_sql(as.integer(x)),            sql("CAST(`x` AS INT)"))
  expect_equal(translate_sql(as.character(x)),          sql("CAST(`x` AS STRING)"))
})

test_that("custom aggregators translated correctly", {
  local_con(simulate_odbc())

  expect_equal(
    translate_sql(sd(x, na.rm = TRUE), window = FALSE),
    sql("STDDEV_SAMP(`x`)")
  )
})

test_that("custom window functions translated correctly", {
  local_con(simulate_odbc())

  expect_equal(
    translate_sql(sd(x, na.rm = TRUE)),
    sql("STDDEV_SAMP(`x`) OVER ()")
  )
})