DRDataRaft/ docs
GitHub ↗

dr_transform_dbt()

Writes the incoming table to an explicitly named staging relation, closes that connection, runs dbt build for the selected model, then opens a fresh connection to read the successfully built relation. The dbt model must reference the supplied staging table; this adapter never ignores its input.

Usage

dr_transform_dbt(
  project,
  model,
  connection,
  input,
  full_refresh = FALSE,
  vars = list(),
  echo = FALSE,
  timeout = Inf
)

Arguments

project
A dr_dbt_project() specification.


model
Exact materialized dbt model unique ID, for example "model.shop.customer_revenue".


connection
Zero-argument function opening a DBI connection to the database used by dbt. Return a new connection on every call.


input
Dedicated staging table, as a string or DBI::Id(). Existing table contents are replaced. Its schema must already exist.


full_refresh, vars, echo, timeout
Passed to dr_dbt_build().

Value

A deferred transformation adapter for dataraft.core::dr_step_transform().

Details

input is replaced on every execution. Use a dedicated staging table that is not managed by a dbt seed or model, and coordinate concurrent writers. dbt owns SQL dependencies, tests and incremental strategies. Staging and dbt model changes are external side effects; the product's final quality gate controls its publication target, not a rollback of dbt's database changes. The returned table is materialized so every factory-owned connection closes. Invocation ID and selected model are attached as dr_transform_metadata.

Examples

# dbt's selected model must read the dedicated staged_orders relation.
project <- dr_dbt_project("analytics", profiles_dir = "analytics")
step <- dr_transform_dbt(project, "model.shop.customer_revenue",
  connection = function() DBI::dbConnect(duckdb::duckdb(), "analytics.duckdb"),
  input = "staged_orders")
dataraft.core::dr_inspect(step)

See also

dr_dbt_init(), dr_dbt_build(), dataraft.adapters::dr_source_database()
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.