Data Engineering: Pipelines, Orchestration & Reliability
Back to Reliability and Production Patterns

Data Quality Testing with dbt — Schema Tests to CI/CD

Two dominant approaches to encoding data quality rules. Most production stacks use both. FIND_VIDEO: search 'great expectations vs dbt tests data quality' — recommended channel: Great Expectations / dbt Labs. Aim for 10 min or under.

16 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Built-in Schema Tests — Configuring unique, not null, accepted values, and relationship constraints inside model YAML files.
  2. Custom SQL Tests — Writing standalone SQL assertions in the tests directory to enforce business logic like date boundaries.
  3. Source Freshness Checks — Defining latency SLAs and alert thresholds to monitor data ingestion staleness.
  4. Incremental Model Testing — Restricting test execution to newly ingested data windows to avoid costly full-table scans.
  5. CI/CD Workflow Integration — Configuring GitHub Actions to automate dbt test execution and gate pull request merges.
  6. Dynamic Testing with Macros — Using Jinja macros to create reusable test functions and connect external validation tools.
PDF notes

Frequently asked questions

How does dbt know whether a custom SQL test passed or failed?

dbt executes the query and checks the returned row count. If zero rows are returned, the test passes; if one or more rows are returned, it fails.

What is the difference between warning and error severities in dbt tests?

A warning logs an alert but allows pipeline execution to continue, whereas an error returns a non-zero exit code and halts dependent steps.

Where should source freshness be configured in a dbt project?

Source freshness is configured under the `sources:` block inside model YAML files or `dbt_project.yml` using `loaded_at_field` and threshold rules.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.