Course contents

The Analytics Engineer’s Field Guidedbt 2: make it trustworthyChallenge: dbt 2

Challenge: dbt 2

Challenge: dbt 2

Three situations from a shared project, where macros, tests and contracts meet.

Challenge questions

  1. Alice changes the net_eur macro and writes a unit test on stg_orders, giving rows for source('raw', 'orders') only. stg_orders also refs dim_vat_rates. What happens when the test runs?

    1. It treats dim_vat_rates as empty and runs the test
    2. It reads dim_vat_rates from the warehouse for real
    3. It errors: every ref and source needs its own input
    4. It passes, since only the macro's inputs are checked
  2. fct_orders has an enforced contract and no versions. Alice renames country to country_code in the SQL and in the YAML, in one merge request. Two dashboards read country, and both are declared as exposures. What do you expect?

    1. The exposures fail the build, because they say the dashboards depend on the model
    2. dbt keeps country as an alias for one release, because the contract is enforced
    3. The preflight check fails the build, because the contract remembers the old name from production
    4. It builds, so the dashboards break unless she publishes a v2 beside v1
  3. fct_orders has an enforced contract, with constraints not_null and unique on order_id. A bad load sends the same order twice. What happens on Snowflake?

    1. Both rows land, since only not_null is enforced
    2. Snowflake rejects the second row at insert time
    3. The contract check fails the build before it runs
    4. dbt drops the duplicate, since unique is declared