Skip to content

Data warehouse and report testing: how to verify the numbers the board relies on

B2Bnetwork team · · 6 min

Testing and quality

In brief

You test a data warehouse in four places: reconciliation with the source (did every record and amount arrive), data quality rules after every load (keys, nulls, accepted values, relationships), transformation tests on a small dataset with a hand-calculated result, and regression of report figures after every change. Control totals of amounts and a single definition of each metric matter most. Without them the board receives numbers nobody can defend.

Where a wrong number is born

A figure in a board report passes through several layers. An error can arise in any of them, and in the report it always looks the same: like a wrong number.

LayerTypical errorThe test that catches it
source and extractionpart of a day's records missing, a truncated file, the wrong cut-off daterecord count and sum of amounts compared with the source
loadingduplicates after a rerun, rejected rows without a tracekey uniqueness, a rejection counter
transformationa wrong mapping rule, currency converted at the wrong ratea test on a small dataset with a hand-calculated result
data modellost change history, a record attached to the wrong periodhistory and period tests
reporta filter that cuts out part of the data, a wrong aggregation, permissionscomparing the report with a control query

That is why a single test along the lines of "the report opens and shows numbers" guarantees nothing. Every layer needs its own checks.

Reconciliation with the source

The board's first question is: did everything arrive. Reconciliation answers it by comparing the warehouse with the source system after every load. It checks three things:

  1. Record counts by date and type: how many transactions from November 30 are in the source system, and how many in the warehouse.
  2. Control totals of amounts: the sum of account balances at end of day in the source and in the warehouse, separately for each currency and branch.
  3. Rejected records: how many rows failed validation, why, and whether anyone handled them.

For amounts, the tolerance is zero unless the difference comes from documented rounding. A one-cent difference on a balance total signals that a record went missing or was doubled somewhere. Reconciliation must be automated and must block report publication when it does not match. A manual reconciliation once a quarter will not stop an error in a monthly report.

The same technique underpins data migration testing: there you compare the old and the new system, here the source and the warehouse.

Data quality rules after every load

The second level is rules the data must meet regardless of the source. Data transformation tools ship ready-made tests for this. In dbt, the four built-in ones are: unique values in a column, no null values, values only from an accepted list, and a matching record in another table (referential integrity).

On top of these come business rules only the company knows:

  • a closed account has a zero balance,
  • a loan disbursement date is not later than the first installment date,
  • every policy has an assigned customer and a product from the catalog,
  • the sum of invoice lines matches the header amount.

The rules live next to the data model, in the repository, and run after every load. The results go to a quality dashboard showing the number of violations over time. Measuring and improving data quality is covered in more depth in Data quality.

Testing transformations and metric definitions

The hardest errors sit in the logic: in the rule that calculates a metric. You test them on a small, prepared dataset. An analyst builds a dozen or so records that cover the edge cases and calculates the expected result by hand or in a spreadsheet. The test runs the transformation on that dataset and compares the output with the expected result.

An example for the metric "loans more than 90 days past due": a record exactly 90 days late, a record partly repaid on the cut-off date, a record in a foreign currency, a restructured record, a record that changed status on the last day of the month. Each case is a question about the definition. The answer must be recorded in one place, the metric catalog, or two departments will calculate the same metric differently and both will be "right".

Time deserves separate checks: late-arriving data, the clock changes in October and March, a month end that falls on a weekend and change history in dimensions (for example a customer who moved to another segment mid-year).

Number regression and production controls

Every change to the warehouse can change figures in reports nobody meant to change. The most effective regression test is simple: recalculate the report for a closed period on the old and the new version of the code and compare the results cell by cell. The differences must match what the change was supposed to change. Any other difference is a defect.

In production, the controls keep running. After every load, reconciliations and quality rules run, and the report gets a status: published, or held with a stated reason. Data lineage helps too: a record of which tables and columns produce each report cell. Without it, analyzing a discrepancy takes days.

In banks these requirements also have a supervisory basis. The Basel Committee set out principles for effective risk data aggregation and risk reporting (BCBS 239), among them accuracy, completeness and timeliness of data. This is what it looks like in practice in the case study of a data warehouse for FINREP and COREP reporting.

B2Bnetwork engineers put data and reports in order as part of our Data and reporting service: from a metric dictionary with a definition and owner for each figure to quality checks and reconciliation with the source on every refresh. Choosing a warehouse architecture is covered in ETL or ELT.

Questions and answers

Where should you start testing an existing data warehouse?

With reconciliation against the source for a few of the most important reports: record counts and sums of amounts after every load. That shows fastest whether the data is complete at all. Then quality rules for key tables, and finally transformation tests for the metrics the board asks about most.

Who should set the expected results for metric tests?

The metric owner on the business side, together with a data analyst. The tester prepares the edge cases and asks questions about the definition but should not decide alone whether a loan repaid on the cut-off date is past due. The decision goes into the metric catalog, and the test enforces it.

Can data warehouse testing be fully automated?

Reconciliations, quality rules, transformation tests and number regression can, and they bring the biggest gain because they run after every load. What stays manual is reviewing new reports with users and analyzing discrepancies whose cause is not visible in the data, such as a process change in a source system.

How do you test a warehouse that holds personal data?

Tests in production, such as reconciliations and quality rules, work on totals and counts, so they do not need to show anyone's data. For transformation tests in a test environment, synthetic or anonymized data is the better choice. A production copy with full personal data in a test environment needs a legal basis and the same safeguards as production.

What it looks like in a project

Planning testing for your project? Talk to a test manager.

Let's talk

Read more: Testing and quality

All in Testing and quality →