dm_flatten() updates a table in-place by joining its parent tables into it,
and removes the now integrated parent tables from the dm.
Usage
dm_flatten(
dm,
table,
...,
parent_tables = NULL,
recursive = FALSE,
allow_deep = FALSE,
join = left_join
)Arguments
- dm
A
dmobject.- table
The table to flatten by joining its parent tables. An interesting choice could be for example a fact table in a star schema.
- ...
These dots are for future extensions and must be empty.
- parent_tables
-
Unquoted names of the parent tables to be joined into
table. The order of the tables here determines the order of the joins. IfNULL(the default), all direct parent tables are joined in non-recursive mode, or all reachable ancestor tables in recursive mode.tidyselectis supported, seedplyr::select()for details on the semantics. - recursive
Logical, defaults to
FALSE. IfTRUE, recursively flatten parent tables before joining them intotable. Uses simple recursion: recursively flattening the parents and then doing a join in order. IfFALSE, fails if a parent table has further parents (unlessallow_deepisTRUE). Cannot beTRUEwhenallow_deepisTRUE.- allow_deep
Logical, defaults to
FALSE. Only relevant ifrecursive = FALSE. IfTRUE, parent tables with further parents are allowed and will remain in the result with a foreign-key relationship to the flattened table. Cannot beTRUEwhenrecursiveisTRUE.- join
The type of join to use when combining parent tables, see
dplyr::join(). Defaults todplyr::left_join().nest_joinis not supported. Whenrecursive = TRUE, onlydplyr::left_join(),dplyr::inner_join(), anddplyr::full_join()are supported.
Value
A dm object with the flattened table and removed parent tables.
See also
Other flattening functions:
dm_flatten_to_tbl()
Examples
dm_nycflights13() %>%
dm_select_tbl(-weather) %>%
dm_flatten(flights, recursive = TRUE)
#> Renaming ambiguous columns: %>%
#> dm_rename(airports, name.airports = name) %>%
#> dm_rename(planes, year.planes = year)
#> ── Metadata ────────────────────────────────────────────────────────────────────
#> Tables: `flights`
#> Columns: 35
#> Primary keys: 0
#> Foreign keys: 0
