Elite data quality doesn’t happen by accident—it’s the result of intentional testing, smart monitoring, and ruthless automation. Thankfully, with dbt, you can build an airtight data quality framework. And with Elementary, you can take that framework to a whole new level of visibility and trust.
Here’s how to level-up your pipelines with dbt + Elementary: built-in tests, custom tests, real-world examples, and advanced observability.
These are your foundational guards against dirty data.
not_null
columns:
- name: user_id
tests:
- not_null
unique
columns:
- name: order_id
tests:
- unique
accepted_values
columns:
- name: status
tests:
- accepted_values:
values: ['active', 'inactive', 'pending']
relationships
columns:
- name: customer_id
tests:
- relationships:
to: ref('dim_customers')
field: id
When the built-ins don’t cut it, you roll your own.
{% test positive_values(model, column_name) %}
SELECT *
FROM {{ model }}
WHERE {{ column_name }} <= 0
{% endtest %}
columns:
- name: price
tests:
- positive_values
{% test past_date(model, column_name) %}
SELECT *
FROM {{ model }}
WHERE {{ column_name }} > current_date
{% endtest %}
{% test churned_users_have_churn_date(model) %}
SELECT *
FROM {{ model }}
WHERE status = 'churned' AND churn_date IS NULL
{% endtest %}
Elementary is a powerful open-source tool that analyzes dbt artifacts (run_results.json
, manifest.json
) and generates a full data observability report.
Tracks test failures over time
Groups failures by model/test/type
Highlights freshness issues, row count anomalies, and schema changes
Lets you drill into failed rows
Sends Slack/Email alerts on failures
Automatically publishes a sleek web UI or pushes to dbt Cloud/S3
Use severity: warn
for soft failures:
tests:
- unique:
severity: warn
Run in CI/CD pipelines (GitHub Actions, GitLab, dbt Cloud).
Track test coverage using manifest.json
and visualize it in Elementary.
Integrate with Airflow or orchestrators to auto-monitor tests daily.
Combining dbt’s test framework with Elementary’s observability layer creates a best-in-class data quality system:
✅ Built-in tests
✅ Custom macros
✅ Alerts and dashboards
✅ Stakeholder visibility
Whether you're just getting started or scaling out a mature data platform, this duo will help you deliver clean, reliable, and trusted data—consistently.