mk_td: Make a table description directly.

View source: R/table_source.R

mk_tdR Documentation

Make a table description directly.

Description

Build minimal structures (table name and column names) needed to represent data from a remote table.

Usage

mk_td(
  table_name,
  columns,
  ...,
  qualifiers = NULL,
  q_table_name = NULL,
  head_sample = NULL,
  limit_was = NULL
)

table_source(
  table_name,
  columns,
  ...,
  qualifiers = NULL,
  q_table_name = NULL,
  head_sample = NULL,
  limit_was = NULL
)

Arguments

table_name

character, name of table

columns

character, column names of table (non-empty and unique values).

...

not used, force later argument to bind by name

qualifiers

optional named ordered vector of strings carrying additional db hierarchy terms, such as schema.

q_table_name

optional character, qualified table name, note: has to be re-generated for different DB connections.

head_sample

optional, head_sample of table as an example

limit_was

optional, row limit used to produce head_sample.

Details

Generate a query that returns contents of a table, we could try to eliminate this (replace the query with the table name), but there are features one can work with with the query in place and SQL optimizers likely make this zero-cost anyway.

Value

a relop representation of the data

Functions

  • table_source(): old name for mk_td

See Also

db_td, local_td

db_td, local_td, rq_copy_to, materialize, execute, to_sql

Examples


if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
  my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
  rq_copy_to(my_db,
             'd',
             data.frame(AUC = 0.6, R2 = 0.2),
             overwrite = TRUE,
             temporary = TRUE)
  d <- mk_td('d',
                    columns = c("AUC", "R2"))
  print(d)
  sql <- to_sql(d, my_db)
  cat(sql)
  print(DBI::dbGetQuery(my_db, sql))
  DBI::dbDisconnect(my_db)
}


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