Add to last argument and pass all others through.
to_sql(
x,
db,
...,
limit = NULL,
source_limit = NULL,
indent_level = 0,
tnum = mk_tmp_name_source("tsql"),
append_cr = TRUE,
using = NULL
)
rquery operation tree.
DBI database handle or rquery_db_info object.
generic additional arguments (not used).
numeric if not NULL limit result to this many rows.
numeric if not NULL limit sources to this many rows.
level to indent.
temp sub-query name generator.
logical if TRUE end with CR.
character, if not NULL set of columns used from above.
SQL command
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
d1 <- rq_copy_to(my_db, 'd1',
data.frame(AUC = 0.6, R2 = 0.2))
d2 <- rq_copy_to(my_db, 'd2',
data.frame(AUC = 0.6, D = 0.3))
optree <- natural_join(d1, d2, by = "AUC")
cat(format(optree))
print(to_sql(optree, my_db))
DBI::dbDisconnect(my_db)
}
#> mk_td("d1", c(
#> "AUC",
#> "R2")) %.>%
#> natural_join(.,
#> mk_td("d2", c(
#> "AUC",
#> "D")),
#> jointype = "INNER", by = c('AUC'))
#> [1] "SELECT\n COALESCE(`tsql_03063649249261915942_0000000000`.`AUC`, `tsql_03063649249261915942_0000000001`.`AUC`) AS `AUC`,\n `tsql_03063649249261915942_0000000000`.`R2` AS `R2`,\n `tsql_03063649249261915942_0000000001`.`D` AS `D`\nFROM (\n SELECT\n `AUC`,\n `R2`\n FROM\n `d1`\n) `tsql_03063649249261915942_0000000000`\nINNER JOIN (\n SELECT\n `AUC`,\n `D`\n FROM\n `d2`\n) `tsql_03063649249261915942_0000000001`\nON\n `tsql_03063649249261915942_0000000000`.`AUC` = `tsql_03063649249261915942_0000000001`.`AUC`\n"