dbt test
Data tests Types:
Singular: tests related to one or two models, can’t be used as a general test to all the other models.
EX:
Create a SQL statement in the Tests subfolder
Generic: YAML code that is scalable and can be applied to multiple models.
unique
not null
relationships
accepted_values
version: 2
models:
- name: stg_jaffle_shop__customers
columns:
- name: customer_id
tests:
- unique
- not_null
- name: stg_jaffle_shop__orders
columns:
- name: status
tests:
- accepted_values:
values:
["shipped", "completed", "return_pending", "returned", "placed"]
sources:
- name: jaffle_shop
database: jaffle_shop
schema: dbo
tables:
- name: customers
columns:
- name: id
tests:
- unique
- not_null
- name: orders
columns:
- name: id
tests:
- unique
- not_null
- name: payments
dbt test --select source:jaffle_shop
dbt build
→ runs + tests each model step by step