This backend supports IBM DB2 databases, typically accessed via ODBC.
Use dialect_db2() with lazy_frame() to see simulated SQL without
connecting to a live database.
Key differences for this backend are:
Uses
FETCH FIRST n ROWS ONLYinstead ofLIMIT nUses double quotes for identifier quoting
paste()uses||DB2-specific data type names for casts (e.g.
VARCHAR(255),DOUBLE)Date component extraction via
YEAR(),MONTH(), ...,DAYOFYEAR(),DAYOFWEEK(),QUARTER(),WEEK()str_flatten()usesLISTAGGrunif()translates toRAND()Regular expression functions (DB2 11.1+)
See vignette("translation-function") and vignette("translation-verb") for
details of overall translation technology.
Examples
library(dplyr, warn.conflicts = FALSE)
lf <- lazy_frame(a = TRUE, b = 1, c = 2, d = "z", con = dialect_db2())
lf |> head()
#> <SQL>
#> SELECT *
#> FROM "df"
#> FETCH FIRST 6 ROWS ONLY
lf |> transmute(x = paste0(d, " times"))
#> <SQL>
#> SELECT "d" || ' times' AS "x"
#> FROM "df"
lf |> summarise(x = sd(b, na.rm = TRUE))
#> <SQL>
#> SELECT STDDEV_SAMP("b") AS "x"
#> FROM "df"
