Example of automatic insertion of a rename node on a join.

library("rquery")
library("wrapr")

raw_connection <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
RSQLite::initExtension(raw_connection)
db <- rquery_db_info(
  connection = raw_connection,
  is_dbi = TRUE,
  connection_options = rq_connection_tests(raw_connection))

t1l <- data.frame(a = c(1, 2), b = c(3, 4))
t1r <- rq_copy_to(db, "t1r", t1l)
t2l <- data.frame(c = c(2, 1), d = c(6, 5))
t2r <- rq_copy_to(db, "t2r", t2l)

ops <- natural_join(t1r, t2r, by = c("a" = "c"))

cat(format(ops))

# cat(to_sql(ops, db))

execute(db, ops) %.>%
  knitr::kable(.)

DBI::dbDisconnect(raw_connection)

library("rqdatatable")

natural_join(t1l, t2l, by = c("a" = "c"))

ex_data_table(ops,
              tables = list("t1r" = t1l, "t2r" = t2l)) %.>%
  knitr::kable(.)

list("t1r" = t1l, "t2r" = t2l) %.>% 
  ops %.>%
  knitr::kable(.)


WinVector/rquery documentation built on Aug. 24, 2023, 11:12 a.m.