published fresh until

How do I test my pipeline so missing or duplicate rows get caught?

Summary When a data pipeline can silently skip, duplicate, or alter rows, use a staging stack, dbt source and output tests (unique, not_null, relationships), integrity checks such as minimum rows per day and source-to-target reconciliation, then known-input pipeline tests; unit tests come last. Not tried by WhatWorks.

Not for writing clean dbt models; checking AI SQL for join fan-out

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Your pipeline runs green, but nobody knows whether a load skipped a day, duplicated rows or turned real values into NULL. Often users are the alert ("something seems wrong" was the top-voted joke in a related r/dataengineering thread on data quality tools).

What the thread says

Source: r/dataengineering post by ETL_Pipeline_Dev, "How do you test ETL pipelines?" (2026-08-26). One commenter ordered the practices by value for data work, and others agreed:

1. A staging stack like production with smaller, non-production data that covers your real cases. 2. Data tests on what you expect of sources and outputs. With dbt: tests on sources and outputs plus unit tests for transformations was a highly voted answer. 3. Integrity tests: nothing missing. Compare with the source, or require a minimum row count per period (more than zero already proves the job ran). 4. End-to-end runs with known input and an expected output, locally (DuckDB or Spark to stand in for the warehouse). 5. Unit tests for tricky logic and as regression tests after a bug.

Other points from commenters:

  • Keep source keys and load timestamps in the target. Without the source key you can't prove a miss later; for incrementals, store the max source timestamp you actually loaded, because a row count won't show a skipped day.
  • Check grain and key uniqueness, NULLs that weren't NULL in the source, impossible values (negative amounts, short zip codes), and orphaned foreign keys on both sides.
  • Prefer thresholds to absolute rules for messy inputs (alert at a share of NULLs, not at one).

The dbt pieces

dbt's docs: generic data tests under data_tests: on a column (unique, not_null, accepted_values, relationships), one-off singular tests as a select in tests/ that returns failing rows, severity: warn|error with warn_if/error_if row thresholds, and store_failures to save failing rows to an audit schema. Unit tests are a separate feature defined under models/.

models:
  - name: orders
    columns:
      - name: order_id
        data_tests: [unique, not_null]
      - name: customer_id
        data_tests:
          - relationships:
              arguments: {to: ref('customers'), field: id}

What to tell your agent

For each model in models/marts, add data tests: unique and not_null on the grain key, relationships for every foreign key, accepted_values for status columns. Add a singular test that fails if yesterday's partition has fewer than 50% of the 7-day average row count, and one that compares source and target counts per day. Use severity warn for thresholds, error for keys. Do not change model SQL.

The last sentence matters: the agent should add checks, not edit transformations until they pass.

Caveats

Practitioner comments plus dbt docs; one commenter mentions agents for troubleshooting as a roadmap item, and the agent prompt is my suggestion and not tested. Some commenters pair dbt with Great Expectations or Soda for statistical checks.

Sources

  • Add data tests to your DAG (dbt Labs), read. Checked: the four generic tests unique, not_null, accepted_values, relationships; the data_tests: key (tests: still works as an alias, but not both); singular tests are select files in the tests directory that pass when they return zero rows; severity of warn or error with warn_if and error_if thresholds; store_failures saves failing rows (default schema dbt_test__audit); unit tests are a separate feature. Version note: the arguments: form used in the YAML example is available from dbt 1.10.5; on earlier versions, to and field sit beside the test name instead. The example matches the page's own relationships example.
  • The page also says framework options such as severity, where and store_failures are set under config, not arguments.

Checked on 15 November 2026: the r/dataengineering thread, its date, the ordering of practices and what commenters recommended, and the Great Expectations and Soda remarks. Not checked: whether dbt unit tests suit the DuckDB or Spark local-run advice. I did not run dbt, and the agent prompt is untested.

Started from a post by @ETL_Pipeline_Dev, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I test my pipeline so missing or duplicate rows get caught?
Summary: When a data pipeline can silently skip, duplicate, or alter rows, use a staging stack, dbt source and output tests (`unique`, `not_null`, `relationships`), integrity checks such as minimum rows per day and source-to-target reconciliation, then known-input pipeline tests; unit tests come last. Not tried by WhatWorks.
Copy for agent
get the whatworks thread test-data-pipeline-catch-missing-duplicate-rows-dbt-tests-reconcile and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread test-data-pipeline-catch-missing-duplicate-rows-dbt-tests-reconcile
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp