DRDataRaft/ docs
GitHub ↗

dr_dbt_model()

Build a dm::dm() from explicit relation names in a dbt manifest. The lake must refer to the same catalog used by the dbt project. SQL dependencies do not imply relational keys; declare keys explicitly when needed.

Usage

dr_dbt_model(
  lake,
  x,
  tables = NULL,
  database = "lake",
  primary_keys = list(),
  foreign_keys = list(),
  check = TRUE
)

Arguments

lake
A connected lake from dataraft.lake::dr_connect_lake().


x
A dr_dbt_result, or a character scalar giving an artifact directory.


tables
Optional named character vector mapping R table aliases to dbt unique IDs, such as c(sales = "model.shop.sales"). By default includes all non-ephemeral models, seeds and snapshots. Use a subset after selected builds.


database
Character scalar: the attachment name in the R connection. Defaults to "lake", as created by dataraft.lake::dr_connect_lake().


primary_keys
Named list of character vectors, keyed by table alias.


foreign_keys
List of lists containing table, columns, ref_table, ref_columns.


check
Validate all declared keys and relationships.

Value

A lazy dm object with a dr_dbt_nodes attribute mapping aliases to dbt unique IDs. Key violations raise dr_model_invalid when check is TRUE; SQL and connection errors are propagated.

Details

Relations are current dbt tables or views, not immutable dataraft releases. The returned lazy model borrows the supplied connection; keep it open while querying. Ephemeral models cannot be opened. This function does not certify that tables were successfully built or that they still match the artifacts.

Examples

\dontshow{if (nzchar(Sys.getenv("DATARAFT_DBT_EXAMPLE_PROJECT"))) withAutoprint(\{ # examplesIf}
# See vignette("dbt-workflows") for a complete build and reconnect example.
project <- dr_dbt_project(Sys.getenv("DATARAFT_DBT_EXAMPLE_PROJECT"))
project
\dontshow{\}) # examplesIf}

See also

dataraft.core::dr_model() for immutable releases, dr_dbt_lineage()
Documentation source snapshot · View source at 3a9d744 ↗
Code examples are documented source examples; they are not executed in this website build.

Search documentation

Search functions, packages and guides.