version: 2
sources:
- name: jaffle_shop
description: a clone of a Postgres application database
database: raw
tables:
- name: customers
description: the raw customer data
columns:
- name: id
description: primary key of raw customer data
tests:
- unique
- not_null
- name: orders
description: the raw orders data
columns:
- name: id
description: primary key of raw orders data
tests:
- unique
- not_null
{{
config(
materialized="incremental",
unique_key="page_view_id" -- This line is the key to replace duplicates
)
}}
with events as (
select * from {{ source('schema', 'table') }}
{% if is_incremental() %}
where collector_tstamp >= ( select dateadd('day', -3, max(max_collector_tstamp)) from {{ this }}
{% endif %}
)
dbt run --Materialize models
dbt snapshot --Run models in snapshot folder only
dbt deps --Run and install dependencies
dbt run-operation required_tests --Run tests defined in dbt_project.yml
version: 2
sources:
- name: jaffle_shop
description: a clone of a Postgres application database
database: raw
tables:
- name: customers
description: the raw customer data
columns:
- name: id
description: primary key of raw customer data
tests:
- unique
- not_null
- name: orders
description: the raw orders data
columns:
- name: id
description: primary key of raw orders data
tests:
- unique
- not_null
models:
advanced_testing:
# checks for every model under models directory should have unique and not_null test
+required_tests: {"unique.*|not_null": 2}
# checks for 'exclude' directory models should have unique and not_null test
exclude:
+required_tests: {"unique.*|not_null": 2}
# checks for 'marts' directory models should have relationship test
marts:
+required_tests: {'relationship.*': 1}
Comments