A data quality charter protects no dashboard. A rule written as a test, run on every load and owned by a named person does. How to measure where you start, how large companies test their data, and the four-step method, with a worked example.
Most data quality programmes start with a document: definitions, principles, a responsibility matrix. Six months later the document exists, and the numbers in the leadership meeting are still wrong. The intent is not the problem. The problem is that no rule is checked at the moment the data arrives.
Our approach fits in one sentence: every quality rule becomes an automated test, run on every load, with an owner who receives the alert. It is not a new idea. Software teams have tested their code this way for decades, and the companies that run the largest data platforms now test their data the same way. This article shows how they do it, and how to apply it at the scale of a mid-sized company.
How bad is it, really?
Before testing anything, measure. In a study published in the Harvard Business Review in 2017, Tadhg Nagle, Thomas Redman and David Sammon asked 75 executives to take the last 100 units of work their own departments had produced and to check them for errors in the most important fields. Only 3% of the resulting scores fell in the range the authors considered acceptable, at least 97 records correct out of 100.
The method behind that study, which Redman had described a year earlier in the same magazine, is worth copying because it takes an afternoon and no tool:
- take the last 100 records your team created: invoices, customer records, orders;
- with two or three people who know the data, choose the handful of fields that matter most;
- go through the records one by one and mark each one that has an error in any of those fields;
- count the records with no error at all. That count is your score out of 100.
The result is rarely comfortable, and that is the point. It turns "our data is not great" into a number, measured on your own work, that leadership can follow over time.
Start from critical data
Not all data deserves checks. Start with the data behind a decision or an obligation:
- revenue and margins presented to leadership;
- customer and supplier data used for invoicing, with their ICE;
- stock and orders that trigger a purchase or a delivery;
- figures sent to a bank, a shareholder or a public authority.
For each item, write one line: who uses it, for which decision, and what happens when it is wrong. That last column sets the priority. An error that blocks an invoice comes before an error that shifts a chart.
How large platforms test their data
Two papers describe how companies with very large data platforms turned quality rules into code.
At Amazon, Sebastian Schelter and his co-authors built a system they describe as "unit tests for data", published at the VLDB conference in 2018. Teams declare the constraints their data must meet: a column is complete, values are unique, a number stays within a range. The system computes those checks as ordinary queries on each new batch of data, and it is released as an open-source library called Deequ. Amazon's own description adds the part that matters most: when a check fails, the dataset is not published, so the error does not reach the teams that use it.
At Google, Eric Breck and his co-authors described the data validation system used in the company's machine learning platform, in a paper presented at the SysML conference in 2019. Each dataset has a schema: the expected columns, types, value ranges and how complete each field should be. Every new batch is compared with that schema before it is used. The paper reports that hundreds of product teams rely on it to monitor several petabytes of data a day.
Neither approach needs Amazon's or Google's resources. The idea is the same at every scale: write what the data must look like, check every new load against it, and stop or flag what does not match.
Turn each rule into a test
A useful rule can be checked by a machine, with no interpretation. "Customer data must be reliable" is not a rule. These are:
- the ICE is filled in and has 15 digits;
- one ICE appears on only one active customer record;
- an invoice amount equals the sum of its lines;
- an order references a product that exists in the catalogue;
- the sales table was updated less than 24 hours ago.
Most data transformation tools let you write these as tests next to the code that produces the data. dbt, for example, ships four generic tests that cover a large share of everyday rules: not_null (no empty values), unique (no duplicates), accepted_values (only values from a list) and relationships (every row points to a row that exists in another table). Anything else becomes a custom test written in SQL. The tests live in the same repository, go through the same review, and run on every load.
Illustrative example: 7 customer records go through 4 quality rules. 4 records are published. 3 go to quarantine: one with no ICE, one duplicate, one invalid email.
The figure above shows the principle on seven customer records: four rules, four records published, three held back with the reason. Nothing in it is specific to customers. The same pattern works for invoices, orders or stock.
Decide what a failed test does
A test is only useful if everyone knows what happens when it fails. There are three options, and each rule needs one of them:
- block: publication stops, yesterday's data stays on screen with a clear message, and the owner is alerted. Use it when wrong data would be worse than old data, such as invoicing or figures sent outside the company;
- warn: the data goes through, but the alert is sent and the problem is counted. Use it for rules where a small share of errors is tolerable for a while;
- quarantine: the failing rows are set aside with their reason, and the others go through, the way an ambiguous invoice goes to review without blocking the rest.
dbt calls the first two "error" and "warn", and can store the failing rows in a table so the owner sees exactly which records to fix. Whatever the tool, write the choice next to the rule.
Alerts and owners
A test that fails without telling anyone is useless. Every rule has a named owner on the business side, not only on the technical side:
- the owner decides whether the rule is right and whether it blocks;
- the alert reaches them where they already work, by email or chat, with the number of rows affected and an example;
- a fix time is set per severity, for example same day for a blocking rule and within the week for a warning;
- the fix happens at the source whenever possible, not in the dashboard.
This is the step most often forgotten. Fixing data in the warehouse without fixing the ERP or the CRM means doing it again tomorrow.
Measuring quality over time
Test results are data too. Keep them for every run, and track three numbers per domain:
- the test pass rate, run by run;
- the number of rows in quarantine or in error;
- the average time from an alert to its fix.
Repeat the 100-record measurement every quarter as well. The tests tell you whether known rules hold. The manual measurement catches the errors no rule covers yet, and each one it finds is a candidate for the next test. Present both, once a month, to the same meeting as the numbers they protect.
Where to start
- Measure your starting score on the last 100 records of one critical domain.
- Write ten checkable rules with the domain owner, in one meeting.
- Turn them into tests, decide for each whether it blocks, warns or quarantines, and run them on the history.
- Connect the alerts, then add one domain a month.
This is the core of our governance, quality and master data work. To know where to start in your company, our data platform assessment measures the state of your critical data in two to three weeks and proposes the first rules.
Sources
- Tadhg Nagle, Thomas C. Redman and David Sammon, "Only 3% of Companies' Data Meets Basic Quality Standards", Harvard Business Review, September 2017. hbr.org.
- Thomas C. Redman, "Assess Whether You Have a Data Quality Problem", Harvard Business Review, July 2016. hbr.org.
- Sebastian Schelter et al., "Automating Large-Scale Data Quality Verification", Proceedings of the VLDB Endowment, vol. 11, no. 12, 2018, pp. 1781-1794. vldb.org.
- AWS Big Data Blog, "Test data quality at scale with Deequ". aws.amazon.com.
- Eric Breck, Neoklis Polyzotis, Sudip Roy, Steven Euijong Whang and Martin Zinkevich, "Data Validation for Machine Learning", Proceedings of SysML, 2019. research.google.
- dbt documentation, "Add data tests to your DAG". docs.getdbt.com.

