to_sql: Return SQL implementation of operation tree.

to_sqlR Documentation

Return SQL implementation of operation tree.

Description

Add to last argument and pass all others through.

Usage

to_sql(
  x,
  db,
  ...,
  limit = NULL,
  source_limit = NULL,
  indent_level = 0,
  tnum = mk_tmp_name_source("tsql"),
  append_cr = TRUE,
  using = NULL
)

Arguments

x

rquery operation tree.

db

DBI database handle or rquery_db_info object.

...

generic additional arguments (not used).

limit

numeric if not NULL limit result to this many rows.

source_limit

numeric if not NULL limit sources to this many rows.

indent_level

level to indent.

tnum

temp sub-query name generator.

append_cr

logical if TRUE end with CR.

using

character, if not NULL set of columns used from above.

Value

SQL command

See Also

db_td, materialize, execute, rq_copy_to, mk_td

Examples


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)
}


rquery documentation built on Aug. 20, 2023, 9:06 a.m.