Data and analytics testing
Check that the figures on a report match the source data, find the first place they differ and agree what each number means.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: checking a school's report cards. Each mark on a report card should match the exam paper. The average should add up from the marks. If a child has 6 exams, the card should not list 7. A good check goes back to the papers.
Daily List is a to-do list app. Nina has a weekly chart of finished tasks. It says 7 were finished on the busy days. Tom counts the finished tasks in the database and gets 6. One task seems to have been counted twice.
Tom does not guess. He goes back one step at a time, from the chart to the report table, and from the table to the stored tasks. He finds a place where one task appears in two rows. That is the extra one.
This is data and analytics testing: checking that the numbers people read on reports match the data they came from.
The picture has a limit. A report card has a few marks. A report may use millions of rows, and the rules for it may be written in many places.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Checking that the numbers people read match the data they came from, one step at a time.
- Read the rule
- Query the source
- Compare each step
- Report the first difference
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| A mark on the report card | A figure on the report |
| The exam paper | The source data |
| Adding the marks again | An independent query |
| The teacher's marking rule | The metric definition |
WHERE THIS PICTURE STOPS
- A report card has a few marks. A report may have millions of rows.
- An exam paper is one piece of paper. Data passes through many steps.
- A teacher checks by eye. A tester writes a query.
HOOK
Back to the paper, step by step.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
If a number on a chart looks wrong, usually go back one step at a time toward the source until the first difference shows.
| In the trick | What it stands for |
|---|---|
| Chart | a weekly chart of finished tasks |
| Source | count the finished tasks in the database |
The business rule behind the number is itself unclear, so no step can be called wrong.
TELL A FRIEND
Checking a school's report cards by going back to the exam papers and adding the marks again.
OFTEN MIXED UP WITH How do you know the right answer? Test oracles. The oracle lesson asks how you know a result is right. This lesson uses the source data as that answer for a report.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Grain (Kimball Group dimensional modeling techniques) ↗ — Kimball Group · The grain states exactly what one row of a fact table means; do not mix grains in one table (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Add data tests to your DAG (dbt documentation) ↗ — dbt Labs · Built-in tests unique, not_null, accepted_values and relationships; a test passes when its query returns zero rows (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
expect_table_row_count_to_equal (Great Expectations) ↗ — Great Expectations · A row count expectation and one that compares row counts between two tables (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Extract, transform, load (ETL) testing: testing in ETL and data-centric projects (EuroSTAR Huddle) ↗ — EuroSTAR Huddle · Testing in extract, transform, load and other data-centric projects (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.