cdr_join_tbls: Join primary and deltas tables

View source: R/cdr_join_tbls.R

cdr_join_tblsR Documentation

Join primary and deltas tables

Description

Join data from db_tbl and recent change values from chg_log tables. Attaches most recent 'WHO_EDITED' and 'WHEN_EDITED' form deltas table to primary table.

Usage

cdr_join_tbls(db_tbl, chg_log_tbl, key_col)

Arguments

db_tbl

primary table from DB

chg_log_tbl

deltas table from DB

key_col

the name of the unique ID column in the primary table

Value

tibble of the joined tables

Examples

chg_log_r_tbl <- structure(
list(
  OBS_ID = c( "ID-001", "ID-002"),
  FIELD = c("Species", "Sepal.Width"),
  CHG_FROM = c("setosa", "3.5"),
  CHG_TO = c("set", "5"),
  WHO_EDITED = c("joe", "fred"),
  WHEN_EDITED = c("11/29/2023, 1:36:46 AM", "11/28/2023, 5:39:21 PM")
),
class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -2L)
)
primary_r_tbl <- cdr_make_unique_ids(iris)
cdr_join_tbls(primary_r_tbl, chg_log_r_tbl, key_col = 'UID')


eauleaf/crudr documentation built on Jan. 29, 2024, 4:39 p.m.