dbt Fundamentals
Back to Contracts, Exposures & Unit Tests

Lab: Contracts + Exposure + Unit Test (Green dbt build)

Harden a legacy dbt project; finish with dbt build exit 0.

61 minutesProject submission
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Assignment Instructions

Brief

Harden an existing dbt project (starter attached, built on the W4 stg_orders shape) with the three enterprise gates. Finish with a green dbt build.

Tasks

  1. Contract: enforce mart_daily_revenue (day: date not_null, revenue_cents: numeric not_null). Show the build failing first by feeding a bad row, then fix and rebuild green.
  2. Exposure: declare one dashboard exposure for a revenue dashboard reading the mart. Paste dbt ls --select +exposure:<name> output proving lineage resolves.
  3. Unit test: write a unit_tests YAML block for the revenue aggregation (given 3 input rows incl. one refund, expect exact output). dbt test --select test_type:unit must pass.

Acceptance (deterministic checks before review)

  • dbt build exits 0 with contract enforced (paste log tail).
  • Exposure resolves in dbt ls output (paste output).
  • Unit test passes (paste dbt test summary).
  • One intentional contract-break demonstrated (bad row rejected, paste error).

Starter

Legacy dbt project skeleton + seed CSV + TODO-marked YAML files attached.

Checking your access…