Please see vignette('DependencySorting', package = 'rquery') and vignette('joinController', package= 'rquery') for more details.

actualize_join_plan(
  columnJoinPlan,
  ...,
  jointype = "LEFT",
  add_ind_cols = FALSE,
  checkColClasses = FALSE
)

Arguments

columnJoinPlan

columns to join, from build_join_plan (and likely altered by user). Note: no column names must intersect with names of the form table_CLEANEDTABNAME_present.

...

force later arguments to bind by name.

jointype

character, type of join to perform ("LEFT", "INNER", "RIGHT", ...).

add_ind_cols

logical, if TRUE add indicators showing which tables supplied rows.

checkColClasses

logical if true check for exact class name matches

Value

join optree

See also

Examples

if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) { my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:") # example data DBI::dbWriteTable(my_db, "meas1", data.frame(id= c(1,2), weight= c(200, 120), height= c(60, 14))) DBI::dbWriteTable(my_db, "meas2", data.frame(pid= c(2,3), weight= c(105, 110), width= 1)) # get the initial description of table defs tDesc <- describe_tables(my_db, qc(meas1, meas2)) # declare keys (and give them consitent names) tDesc$keys[[1]] <- list(PatientID= 'id') tDesc$keys[[2]] <- list(PatientID= 'pid') # build the column join plan columnJoinPlan <- build_join_plan(tDesc) # decide we don't want the width column columnJoinPlan$want[columnJoinPlan$resultColumn=='width'] <- FALSE # double check our plan if(!is.null(inspect_join_plan(tDesc, columnJoinPlan, checkColClasses= TRUE))) { stop("bad join plan") } # actualize as left join op_tree optree <- actualize_join_plan(columnJoinPlan, checkColClasses= TRUE) cat(format(optree)) print(execute(my_db, optree)) if(requireNamespace("DiagrammeR", quietly = TRUE)) { DiagrammeR::grViz(op_diagram(optree)) } DBI::dbDisconnect(my_db) }
#> mk_td("meas1", c( #> "id", #> "weight", #> "height")) %.>% #> rename_columns(., #> c('PatientID' = 'id', #> 'meas1_weight' = 'weight')) %.>% #> natural_join(., #> mk_td("meas2", c( #> "pid", #> "weight")) %.>% #> rename_columns(., #> c('PatientID' = 'pid', #> 'meas2_weight' = 'weight')), #> jointype = "LEFT", by = c('PatientID')) #> PatientID meas1_weight height meas2_weight #> 1 1 200 60 NA #> 2 2 120 14 105