V13 Inspect dbt tests and lineage
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.
V13a Run dbt build
Goal: Execute SQL models and tests.
Prerequisites: V12; processx.
Build runs in a separate CLI process. A failure can be inspected as a result before the course marks the step unsuccessful.
training_step(
"V13a",
{
dbt_result <- dataraft.dbt::dr_dbt_build(
dbt_project,
echo = TRUE,
stop_on_failure = FALSE
)
print(dataraft.dbt::dr_dbt_status(dbt_result))
stopifnot(isTRUE(dbt_result$success))
},
needs = c("V12"),
packages = c("processx"),
enabled = training_options$dbt,
optional = TRUE
)Expected result: Successful model and test nodes.
Task: What should you inspect after a failed build?
Show solution
Status, stdout/stderr and artifact errors. Do not mistake old artifacts for a new success.
V13 Inspect dbt tests and lineage
Goal: Read the corresponding artifacts.
Prerequisites: V13a.
A separate test run checks the built models. Lineage comes from their artifacts.
training_step(
"V13",
{
dbt_test_result <- dataraft.dbt::dr_dbt_test(dbt_project, echo = FALSE)
print(dataraft.dbt::dr_dbt_status(dbt_test_result))
print(dataraft.dbt::dr_dbt_lineage(dbt_result))
},
needs = c("V13a"),
enabled = training_options$dbt,
optional = TRUE
)Expected result: Test results and directed model dependencies.
Task: Is an R rule automatically covered by a dbt test?
Show solution
No. Tests must be explicitly defined or translated.