dm_flatten: Flatten a table in a 'dm' by joining its parent tables

View source: R/dm-flatten.R

dm_flattenR Documentation

Flatten a table in a dm by joining its parent tables

Description

[Experimental]

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 dm object.

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

[Experimental]

Unquoted names of the parent tables to be joined into table. The order of the tables here determines the order of the joins. If NULL (the default), all direct parent tables are joined in non-recursive mode, or all reachable ancestor tables in recursive mode. tidyselect is supported, see dplyr::select() for details on the semantics.

recursive

Logical, defaults to FALSE. If TRUE, recursively flatten parent tables before joining them into table. Uses simple recursion: recursively flattening the parents and then doing a join in order. If FALSE, fails if a parent table has further parents (unless allow_deep is TRUE). Cannot be TRUE when allow_deep is TRUE.

allow_deep

Logical, defaults to FALSE. Only relevant if recursive = FALSE. If TRUE, parent tables with further parents are allowed and will remain in the result with a foreign-key relationship to the flattened table. Cannot be TRUE when recursive is TRUE.

join

The type of join to use when combining parent tables, see dplyr::join(). Defaults to dplyr::left_join(). nest_join is not supported. When recursive = TRUE, only dplyr::left_join(), dplyr::inner_join(), and dplyr::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)


dm documentation built on Feb. 25, 2026, 9:07 a.m.