Build minimal structures (table name and column names) needed to represent data from a remote table.
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 )
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. |
a relop representation of the data
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.
table_source
: old name for mk_td
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) }#> [1] "mk_td(\"d\", c( \"AUC\", \"R2\"))" #> SELECT #> `AUC`, #> `R2` #> FROM #> `d` #> AUC R2 #> 1 0.6 0.2