---
title: "Data quality testing"
description: "incident.io runs data quality tests with dbt's native testing and tackled two problems: flaky relationship tests and slow debugging of failures."
url: "https://swe.quest/articles/data-quality-testing-9aeabda2e89bce8e"
canonical: "https://incident.io/blog/data-quality-testing"
source: "incident.io"
published: "2024-09-04"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["data-pipelines","testing","observability","sql","incident-response"]
---

# Data quality testing

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2024-09-04, 7 min read, Case study. Original: [https://incident.io/blog/data-quality-testing](https://incident.io/blog/data-quality-testing)

## Summary

incident.io runs data quality tests with dbt's native testing and tackled two problems: flaky relationship tests and slow debugging of failures. Relationship tests failed spuriously because transformations ran mid-ingestion, so a child table could reference rows not yet loaded into its parent. The fix overrides dbt's should\_store\_failures, relationships and get\_test\_sql macros so a missing foreign key only fails when it recurs across two consecutive hourly runs. For debugging, a Python step parses run\_results.json and manifest.json to find failed tests and their stored-failure tables, then sends ready-made SELECT queries in the incident API payload so responders can see failing rows directly.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Incidents & postmortems](https://swe.quest/tags/incident-response.md) (Reliability & operations)

## Prerequisites

- dbt models and tests
- Jinja macros
- SQL joins ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

dbt, incident.io, store\_failures, relationship tests, run\_results.json, manifest.json

## Related posts

- [Updating our data stack](https://swe.quest/articles/updating-our-data-stack-8fc5fea19caac0a4.md): incident.io · 2022-08-24 · Medium · 12 min read · Data pipelines, Analytics & OLAP, CI/CD, SQL
  incident.io's two-person data team reworked its BigQuery/dbt analytics stack as the company grew from 10 to 30 people.
- [Data stack 2024](https://swe.quest/articles/data-stack-2024-acc7f40c0d3042d9.md): incident.io · 2024-08-06 · Medium · 9 min read · Analytics & OLAP, Data pipelines, Developer productivity, Incidents & postmortems
  incident.io's 2024 data stack runs Fivetran and Segment into BigQuery, dbt (run via Docker on CircleCI) for transforms, and Hightouch for reverse ETL.
- [Battling database performance](https://swe.quest/articles/battling-database-performance-5c5eb431f69f9020.md): incident.io · 2023-04-20 · Medium · 10 min read · PostgreSQL, Performance engineering, Observability, Go, Incidents & postmortems
  Intermittent API timeouts at incident.io over two weeks traced back to requests blocking on Go's database/sql client-side connection pool, with no single slow query or pool to blame.
- [PostgREST v10: EXPLAIN and Improved Relationship Detection](https://swe.quest/articles/postgrest-v10-explain-and-improved-relationship-detection-44878c605b0df57d.md): Supabase · 2022-08-19 · Medium · 7 min read · PostgreSQL, API design, Performance engineering
  PostgREST v10 adds HTTP-level EXPLAIN support: requests with the \`application/vnd.pgrst.plan\` media type, or supabase-js's \`explain()\` transform, return the PostgreSQL execution plan for reads, writes and RPC, which helps verify that RLS policies are applied and gives you the pg\_stat\_statements query identifier.
- [How we systematically improved our reliability](https://swe.quest/articles/how-we-systematically-improved-our-reliability-84b3da37239114bb.md): Neon · 2026-09-30 · Medium · 11 min read · SRE, Incidents & postmortems, Resilience, PostgreSQL, Deployment
  After two control-plane incidents in one week, each triggered by an external dependency failure that turned into a self-reinforcing loop, Neon rebuilt how it runs reliability for Lakebase Postgres across 70+ cells on three clouds.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
