DRDataRaft/ docs
GitHub ↗

V12 Create a dbt project and bind its source

V12Adapters and additional tools2 steps

Use your current course session. Preparation and course runner · R script ↓

Optional deep dive. Enable only the options named in each block, after preparing its packages or services.

V12a Prepare a local dbt backend

Goal: Prepare separate CLI access.

Prerequisites: dbt=TRUE; dataraft.dbt, lake, duckdb>=1.5.5, bit64, yaml; dbt-duckdb CLI.

A separate local DuckDB lake avoids conflicts with the main connection. It uses the same policy data. The starter's technical names order_id and amount deliberately map to policy_id and premium.

training_step(
  "V12a",
  {
    stopifnot(utils::packageVersion("duckdb") >= "1.5.5")
    dbt_config <- dataraft.lake::dr_lake_config(
      path = file.path(training_root, "dbt-lake"),
      backend = "duckdb",
      layers = c("raw", "staging", "core", "marts")
    )
    dbt_input <- data.frame(
      order_id = linked_policies$policy_id,
      customer_id = linked_policies$customer_id,
      amount = linked_policies$premium
    )
    dbt_raw <- dataraft.lake::dr_ingest(
      dbt_input,
      to = dbt_config,
      name = "training.policies"
    )
    print(dbt_raw)
  },
  needs = c("H16a"),
  packages = c("dataraft.dbt", "dataraft.lake", "duckdb", "bit64", "yaml"),
  enabled = training_options$dbt,
  optional = TRUE
)

Expected result: An accepted RAW release, with no R connection left open to that backend.

Task: Does orders introduce a new business domain?

Show solution

No. It is the starter template's technical interface for the same policy delivery.

V12 Create a dbt project and bind its source

Goal: Generate a minimal SQL workflow.

Prerequisites: V12a; CLI in PATH or TRAINING_DBT_EXECUTABLE.

dr_dbt_init supports this local dbt-duckdb profile. It does not configure arbitrary dbt versions or cloud catalogs.

training_step(
  "V12",
  {
    dbt_executable <- Sys.getenv("TRAINING_DBT_EXECUTABLE", "dbt")
    stopifnot(nzchar(Sys.which(dbt_executable)) || file.exists(dbt_executable))
    dbt_project <- dataraft.dbt::dr_dbt_init(
      file.path(training_root, "dbt-project"),
      dbt_config,
      name = "training_policies",
      executable = dbt_executable,
      sources = list(orders = dbt_raw)
    )
    dbt_project <- dataraft.dbt::dr_dbt_sources(
      dbt_project,
      list(orders = dbt_raw)
    )
    print(dbt_project)
  },
  needs = c("V12a"),
  enabled = training_options$dbt,
  optional = TRUE
)

Expected result: Project files and a source binding to the exact RAW release.

Task: Will a later RAW delivery be selected automatically?

Show solution

No. Update the source binding deliberately.

Search documentation

Search functions, packages and guides.