View source: R/reference.test.R
reference.test | R Documentation |
dbi.table
vs. Reference ImplementationEvaluate an expression including at least one dbi.table
and compare
the result with the Reference Implementation. This function is
primarily for testing and is potentially very slow for large tables.
reference.test(
expr,
envir = parent.frame(),
ignore.row.order = TRUE,
verbose = TRUE
)
expr |
an expression involving at least one |
envir |
an environment. Where to evaluate |
ignore.row.order |
a logical value. This argument is passed to |
verbose |
a logical value. When |
a logical value.
Suppose that id1
identifies a table in a SQL database and that
[i, j, by]
describes a subset/select/summarize operation using
data.table
syntax. The Reference Implementation for this
operation is:
setDT(dbReadTable(conn, id1))[i, j, by]
More generally, for an expression involving multiple SQL database objects
and using data.table
syntax, the Reference Implementation
would be to download each of these objects in their entirety, convert them
to data.table
s, then evaluate the expression.
The goal of the dbi.table is to generate an SQL query that produces the same results set as the Reference Implementation up to row ordering.
library(data.table)
duck <- dbi.catalog(chinook.duckdb)
Album <- duck$main$Album
Artist <- duck$main$Artist
reference.test(merge(Album, Artist, by = "ArtistId"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.