Skip to content

1. Generic tests on a mart

Next steps ยท Next: 2. Macros, Jinja and packages

fct_orders and its 6 data tests

Run the commands from oms_dbt_proj, after a first dbt build --profiles-dir ..

models/marts/finance/finance_schema.yml declares unique, not_null and relationships tests on fct_orders. A schema file only counts if it ends in .yml.

dbt test --profiles-dir . -s fct_orders

Check: 6 data tests pass.

Try it

Add a not_null test to dim_customers.number_of_orders.

Hint

number_of_orders isn't listed in marketing_schema.yml yet. Add it as a new column entry with a tests: list.

Answer

Add this to the end of the columns: list in models/marts/marketing/marketing_schema.yml:

  - name: number_of_orders
    tests:
    - not_null
dbt test --profiles-dir . -s dim_customers

not_null_dim_customers_number_of_orders passes. It passes even for customers with no orders, because dim_customers uses coalesce(..., 0).