R/select_columns.R
select_columns.Rd
Make a select columns node (not a relational operation).
select_columns(source, columns, env = parent.frame())
source | source to select from. |
---|---|
columns | list of distinct column names. |
env | environment to look to. |
select columns node.
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) { my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:") d <- rq_copy_to(my_db, 'd', data.frame(AUC = 0.6, R2 = 0.2)) optree <- select_columns(d, 'AUC') cat(format(optree)) sql <- to_sql(optree, my_db) cat(sql) print(DBI::dbGetQuery(my_db, sql)) DBI::dbDisconnect(my_db) }#> mk_td("d", c( #> "AUC", #> "R2")) %.>% #> select_columns(., #> c('AUC')) #> SELECT #> `AUC` #> FROM ( #> SELECT #> `AUC` #> FROM #> `d` #> ) tsql_75049543662614518432_0000000000 #> AUC #> 1 0.6