Data Engineering for Testers

Data Engineering for Testers: Testing the Pipeline, Not Just the Report

0 Comments

By the time a number is wrong on a dashboard it has passed through five stages and nobody can say which one broke it. Testing the pipeline is how you find out before the dashboard does.

In this article

  • The shape of a pipeline
  • The four checks that catch most pipeline defects
  • Reconciliation, concretely
  • Idempotency and late data
  • Where to put the tests

The shape of a pipeline

  • Source – a database, an API, files, an event stream.
  • Ingest – landing the raw data, unchanged, so you can always go back to it.
  • Transform – cleaning, joining, aggregating. Where most defects are made.
  • Store – warehouse or lake, usually in layers: raw, cleaned, curated.
  • Serve – the dashboard, the API, the model that consumes it.

ETL transforms before loading; ELT loads first and transforms in the warehouse. Most modern stacks are ELT, which is good news for testers: the raw data is still there to compare against.

The four checks that catch most pipeline defects

Check What it catches
Row counts at each stage Silent drops from a bad join or a filter
Null and duplicate rates A source change nobody announced
Referential integrity Orphaned rows after a join
Reconciliation against source Transform logic that is quietly wrong

An inner join that silently drops 4% of rows is the single most common data defect, and a row-count assertion between stages finds it every time.

Reconciliation, concretely

-- does the curated table still agree with the source, to the penny?
WITH src AS (
  SELECT order_date::date AS d, COUNT(*) AS n, SUM(amount) AS total
  FROM raw.orders
  WHERE order_date >= CURRENT_DATE - 7
  GROUP BY 1
), cur AS (
  SELECT order_date AS d, COUNT(*) AS n, SUM(order_amount) AS total
  FROM curated.fact_orders
  WHERE order_date >= CURRENT_DATE - 7
  GROUP BY 1
)
SELECT src.d, src.n, cur.n, src.total, cur.total
FROM src FULL OUTER JOIN cur ON src.d = cur.d
WHERE src.n IS DISTINCT FROM cur.n
   OR ROUND(src.total, 2) IS DISTINCT FROM ROUND(cur.total, 2);

-- zero rows returned is the pass condition

Idempotency and late data

  • Idempotency – run the same job twice with the same input. The result must be identical, not doubled. Test it by actually running it twice; this breaks more often than teams expect.
  • Late-arriving data – a record for Monday that turns up on Wednesday. Does the pipeline restate Monday, or silently put it in Wednesday?
  • Backfill – re-run an old window. Does it overwrite cleanly, or append duplicates?
  • Schema change – a new column, a renamed one, a type change. Does the job fail loudly or carry on with nulls?

Failing loudly is the behaviour you want. A pipeline that silently writes nulls after a schema change produces a dashboard that is wrong and confident.

Where to put the tests

  • Contract tests at the source boundary – schema, types, required fields.
  • Assertions inside the transform job, so a bad run stops rather than publishes.
  • Post-load reconciliation, scheduled, with an alert.
  • A small golden dataset with a known expected output, run on every change to the transform code. This is the regression suite a pipeline usually does not have.

Key points

  • Row counts between stages find the commonest defect there is.
  • Run the job twice – idempotency breaks more often than anyone expects.
  • Zero rows from a reconciliation query is the only pass condition worth having.
  • A pipeline that fails loudly beats one that writes nulls quietly.

Practise this on the free applications at jstestingacademy.co.in/qa-apps – no account needed.