ETL and Warehouse Testing

What is ETL testing?

ETL testing checks that data is extracted, transformed and loaded accurately. It covers row counts, reconciliation, transformation rules and schema checks.

On this page
  1. ETL testing in plain terms
  2. What the pipeline does
  3. Common checks
  4. Running the checks with SQL
  5. How it differs from data warehouse testing
  6. Why row counts are not enough
  7. When to test
  8. In short

ETL testing in plain terms

ETL testing checks that data stays accurate and complete as it moves through an extract, transform and load pipeline. The goal is to confirm that data taken from source systems arrives in the target as the business rules say it should.

Testers usually work from three things: the source data, the mapping rules that describe how each field should change, and the target tables. They compare what should have happened with what did.

What the pipeline does

A typical pipeline has three stages:

  • Extract: copy data from source systems, such as databases, files or applications.
  • Transform: clean and reshape the data and apply business rules. This can mean converting date formats, joining tables, removing duplicates or calculating a new field.
  • Load: write the result into the target, often a data warehouse or a smaller data mart built from it.

ETL testing checks each stage, and especially the handoffs between them, where data can be lost or changed without anyone noticing.

Common checks

  • Row counts. Compare the number of records in the source and the target, and explain any gap, such as duplicates removed on purpose.
  • Reconciliation. Compare totals and key values, such as the sum of order amounts. Hashing row values and comparing the hashes can catch changes that counts miss.
  • Transformation rules. Check that the rules were applied as written. Null handling, trimming, rounding and date logic are frequent sources of error.
  • Schema and data types. Confirm that target columns have the expected types, lengths and constraints.
  • Duplicates and keys. Check that keys are unique in the target. Duplicates can appear when a key is not defined or not enforced.

Running the checks with SQL

Is SQL used for ETL? Often, yes. Many pipelines use SQL for their transformations, and testers often write checks as SQL queries that run against the source and target tables. A common setup is a fixed set of queries that runs after every load, so a failing check is noticed quickly.

A simple row count check looks like this. Run each query on the system it belongs to, because the source and the warehouse are often separate databases:

-- Run on the source system
SELECT COUNT(*) AS source_rows FROM orders;

-- Run on the warehouse, after the load
SELECT COUNT(*) AS target_rows FROM fact_orders;

If the two numbers differ, the difference should be explained before the load is accepted.

How it differs from data warehouse testing

ETL testing is the narrower of the two. Data warehouse testing is the wider term. It also covers the data model, reports, performance and security, so the difference between ETL testing and data warehouse testing comes down to scope.

Why row counts are not enough

A matching row count does not prove the data is right. A load could duplicate some records and drop others, leaving the count unchanged. It could also apply a rounding rule wrongly, or swap two columns that share a data type. That is why row counts usually come with value-level checks.

When to test

Test during development, and again whenever the pipeline or a source system changes. Keep the checks in place after release, because source systems change over time. New fields appear and formats shift.

In short

ETL testing confirms that data is extracted, transformed and loaded correctly, with checks at each stage and at the handoffs between them. It is one part of data warehouse testing, which covers the warehouse as a whole.

The complete guide to etl and warehouse testing

The Difference Between ETL Testing and Data Warehouse Testing
Read the guide

Keep exploring

Guides from other topics

All topics →