data.table based implementation.

# S3 method for relop_natural_join
ex_data_table_step(
  optree,
  ...,
  tables = list(),
  source_usage = NULL,
  source_limit = NULL,
  env = parent.frame()
)

Arguments

optree

relop operations tree.

...

not used, force later arguments to bind by name.

tables

named list map from table names used in nodes to data.tables and data.frames.

source_usage

list mapping source table names to vectors of columns used.

source_limit

if not null limit all table sources to no more than this many rows (used for debugging).

env

environment to work in.

Examples

d1 <- build_frame( "key", "val", "val1" | "a" , 1 , 10 | "b" , 2 , 11 | "c" , 3 , 12 ) d2 <- build_frame( "key", "val", "val2" | "a" , 5 , 13 | "b" , 6 , 14 | "d" , 7 , 15 ) # key matching join optree <- natural_join(local_td(d1), local_td(d2), jointype = "FULL", by = 'key') ex_data_table(optree)
#> key val val1 val2 #> 1 a 1 10 13 #> 2 b 2 11 14 #> 3 c 3 12 NA #> 4 d 7 NA 15
# full cross-product join # (usually with jointype = "FULL", but "LEFT" is more # compatible with rquery field merge semantics). optree2 <- natural_join(local_td(d1), local_td(d2), jointype = "LEFT", by = NULL) ex_data_table(optree2)
#> key val val1 val2 #> 1 a 1 10 13 #> 2 a 1 10 14 #> 3 a 1 10 15 #> 4 b 2 11 13 #> 5 b 2 11 14 #> 6 b 2 11 15 #> 7 c 3 12 13 #> 8 c 3 12 14 #> 9 c 3 12 15
# notice ALL non-"by" fields take coalese to left table.