How public dbt projects test their models
In 265 public dbt projects, the median project tests 32% of its models, and 24% of projects test none.
A software company's revenue and usage tables are models like these: an untested key can double count accounts. These are public projects, not company ones.
Projects in each band of the share of their models with any test (%)
- 63none
- 21<10
- 1910s
- 2020s
- 2230smedian
- 1840s
- 1550s
- 1160s
- 1570s
- 1280s
- 1890s
- 31all
Main limitation These are public repositories, not company projects: many teams keep theirs private. Tests run outside the repository are not seen, and a workflow that runs tests on pull requests does not by itself stop a failing change from merging.
What a team should do: put unique and not_null on the key of every model, a freshness check on every loaded source, and dbt build on every pull request as a required check.
The same distribution with key tests is in the evidence, the four measures in their own figure, and every measure with its interval in the measures table.
| Any test32%of models tested in the median project (26 to 42%); 24% of projects test none; an independent reader agreed within 5 points on 40 of 40 projects checked | Key tests14%of models with a key test in the median project (7 to 22%); 34% of projects have none | Source freshness22%of projects declare it (17 to 27%); predicted under 15%, a miss | Tests on pull requests9%of projects have a workflow file that runs tests on pull requests, by the revised reader, added after the results (6 to 13%); 11% by the original reader. Workflow files, not verified runs |
The headline carries two of the figures the design put in it, chosen after the results. Every measure is in the measures table.
In plain words
Most data teams now keep their transformations as code: SQL files that turn raw tables into the tables dashboards and products read. dbt is a widely used open-source tool for this, and it lets a team attach tests to each table. Four habits are meant to stop the failures that reach executives: a test on every table, a check that each table's key is unique and never empty, a check that each raw source is still arriving, and running those tests before a change merges.
The question is how often real projects have those habits. Surveys ask people what they do; this reads the code. 23,417 public GitHub repositories hold a dbt project file. A random 10,000 of them were checked in full against a rule written before any was measured (no forks, tutorials, courses or packages, at least 20 models, at least 2 contributors; three of its four later changes came after partial screening counts had been seen, one of them only changing how folder listings are read, all before the qualifying count): 265 qualified, which puts the whole frame at about 619 real projects (550 to 697). All 265 were measured.
The answer: the median project tests 32% of its models and checks the key of 14%. 22% of projects declare freshness on any source, and about one in ten has a workflow file that runs its tests on pull requests: 9% by the revised reader, added after the results (6 to 13%), and 11% by the original reader. By the rule fixed before measuring, neither the expected nor the opposite finding held: three of the expected finding's four parts held, and source freshness did not (predicted under 15%; 22% declare it).
Why it matters to a software company: its revenue, usage and funnel tables are the same kind of models. A model whose key is untested can double count accounts the day an upstream join fans out, a source without a freshness check serves yesterday's numbers as today's, and a change merged untested reaches every dashboard at once.
- Model
- One SQL (or Python) file that builds one table or view.
- Test
- A query that fails when the data breaks a rule, attached to a model or one of its columns.
- Key test
- A unique and a not_null test on the same column (or a compound-key or primary-key test): the check that stops duplicate or missing rows.
- Source freshness
- A declared limit on how old the newest row of a raw source may be before the team is warned.
- Pull request
- A proposed change, reviewed before it merges into the main branch.
- CI
- Continuous integration: automation that runs on every pull request.
The evidence
Projects are not one kind. 24% test no model at all and 12% test every model; the rest spread across the range. Pooled over all 32,555 models, 49% have any test and 38% a key test, above the medians. From the median of 32% to the plain average of projects' tested shares, 41%, is the spread: a quarter of projects test nothing and a tenth test everything. From that average to the pooled 49% is size. Size and tested share are barely related across projects (rank correlation −0.01), but the largest tenth of projects hold 70% of all models and test a median 48% of theirs, which lifts the pooled figure. The median project is the fairer benchmark for a team (this reading of the gap was added after the results).
Share of projects (95% interval under each bar)
- Test half or more of their models38%32 to 45%
- Check the key of half or more of their models25%20 to 31%
- Declare freshness on a source22%17 to 27%
- Have a workflow file that runs tests on pull requests (revised reader, added after the results; the original reader: 11%)9%6 to 13%
The figure the protocol fixed as the takeaway, with the interval under each bar.
Any testKey test
Show the data
| Share of the project's models | Projects, any test | Projects, key test |
|---|---|---|
| None | 63 | 89 |
| 1-9% | 21 | 34 |
| 10-19% | 19 | 23 |
| 20-29% | 20 | 24 |
| 30-39% | 22 | 16 |
| 40-49% | 18 | 12 |
| 50-59% | 15 | 14 |
| 60-69% | 11 | 14 |
| 70-79% | 15 | 14 |
| 80-89% | 12 | 9 |
| 90-99% | 18 | 10 |
| All | 31 | 6 |
| Total | 265 | 265 |
Counts of projects; download the rounded shares as distribution.json.
Every measure, with its interval
| Measure | Value | 95% interval | Prediction made before measuring |
|---|---|---|---|
| Median project: share of models with any test | 32% | 26 to 42% | held |
| All models pooled: share with any test | 49% | 37 to 60% | |
| Projects with no test on any model | 24% | 18 to 30% | held |
| Projects with every model tested | 12% | 8 to 16% | |
| Median project: share of models with a key test | 14% | 7 to 22% | |
| All models pooled: share with a key test | 38% | 25 to 49% | held |
| Projects with no key test at all | 34% | 28 to 40% | |
| Projects declaring source freshness | 22% | 17 to 27% | missed |
| Projects running tests on pull requests | 11% | 7 to 15% | held |
| Projects running tests in CI on push only (after merge) | 2% | 0 to 4% | |
| Projects running any dbt command in GitHub Actions | 28% | 22 to 33% | |
| Projects with another CI system's file that runs tests | 1% | 0 to 2% | |
| Projects with at least one unit test | 7% | 4 to 10% |
Intervals are 95% bootstrap intervals over the qualifying public repositories. One account can own several sampled projects (247 owners for 265 projects, at most 5 per owner), so each interval was computed twice, resampling projects and resampling owners, and the page shows the union of the two intervals (the lower of the two lower ends and the higher of the two upper ends).
How far the counts can be trusted (added after the results)
Two checks: how this study's file reader compares with an independent count, and whether a detected workflow really runs on pull requests. These checks were declared and run after the results; the headline carries only figures they support.
- An independent reader. An independent author who never saw the measurement code wrote its own reader from the protocol's definitions. On a random 40 of the 265 projects (the reader failed on 0), the two agree as follows: tested shares within 5 points on 40 of 40 projects and key-tested shares on 40 (median gaps 0 and 0 points; no share differs by more than half a point), the same model count on 39, the same freshness answer on 40 and the same pull-request answer on 35; on that rare yes, this study's reader said yes for 7, the independent reader for 4, both for 3 (Cohen's kappa 0.48).
- The revised reader reads flags given a value after a space, ignores commands only printed or run in push-only jobs, and counts versioned models and the old test folder. It gives a median tested share of 32% (26 to 42%), a median key-tested share of 14% (8 to 21%), freshness in 22% and a pull-request workflow in 9% (6 to 13%) of projects. Against the independent reader it scores: tested shares within 5 points on 40 of 40 projects and key-tested shares on 40 (median gaps 0 and 0 points; no share differs by more than half a point), the same model count on 39, the same freshness answer on 40 and the same pull-request answer on 36; on that rare yes, this study's reader said yes for 6, the independent reader for 4, both for 3 (Cohen's kappa 0.55).
- Runs on record. Of the 30 projects the original reader counts, 21 have at least one run of the matching workflow triggered by a pull request in the platform's records; of the 24 revised-reader counts, 18. A run on record shows the workflow ran on a pull request, not that its test step ran, or ran for this project.
- dbt's own parser was not run: running it executes code from the repositories, which this study's environment did not allow. The independent reader stands in for it.
From every repository to the sample
| Step, each repository counted once at its first failing rule | Repositories |
|---|---|
| Repositories holding a dbt project file | 23,417 |
| Excluded: Owned by a company this site does not name, or by the tool's maker | 284 |
| Excluded: Tutorial, course, demo or template words in the name, topics or description | 5,204 |
| Passed the first three rules | 17,929 |
| A random 10,000 of the 23,417 were read in full: | |
| Of those, passed the first three rules | 7,672 |
| Excluded: A package (holds an integration_tests project) or a project inside a test or example folder | 349 |
| Excluded: Fewer than 20 models | 6,394 |
| Excluded: Built on the standard tutorial data set | 1 |
| Excluded: Fewer than 2 contributors (bots not counted) | 662 |
| Excluded: A read failed (the folder listing or the contributors call) | 1 |
| Qualifying in the screened sample | 265 |
| Estimated qualifying in the whole frame (95% interval) | 619 (550 to 697) |
| Taken for measurement (all of them) | 265 |
| Measured | 265 |
The predictions
The expected finding, its opposite and six predictions were committed before any project was measured.
| Declared before any project was measured | Result | Verdict |
|---|---|---|
| The median project tests between 20% and 50% of its models. | 32% | held |
| Fewer than half of all models, pooled over the sampled projects, have a key test. | 38% | held |
| Under 15% of projects declare source freshness. | 22% | missed |
| Under 30% of projects run tests in CI before a change merges. | 11% | held |
| At least 10% of projects have no test on any model. | 24% | held |
| Projects that run tests in CI before merging have a higher median tested share than projects that do not. Descriptive only: no causal reading. | 72% with tests on pull requests, 30% without | held |
Where your project sits
Count your project's models, the models with at least one test, and the models whose key has both a unique and a not_null test (or a compound-key or primary-key test). The comparison runs in your browser against the 265 measured projects; nothing you type leaves the page.
Enter your numbers and press Compare. Without JavaScript, the chart and its table above give the same distribution.
What this cannot see
- Company projects. Public repositories over-represent open-source data teams, consultancies and personal projects that passed the filters. A private repository at a software company may be better or worse tested; this sample cannot say which.
- Tests run outside the repository. A hosted scheduler can run tests on every pull request with no file in the repository, and a Makefile or script can hide the dbt command. Both read as "no" here. 2% run tests only after a change lands on a branch (on push), and 1% hold another CI system's file that runs tests; neither counts as a test before merge.
- Quality. A count of tests says nothing about whether they test the right thing. A project can test every key and still miss the fault that matters.
- Files that would not parse. 15 of 9,548 YAML files (8 projects) did not parse even after template expressions were removed; tests in them were not counted, so those projects read low.
- A link, not a cause. The 30 projects that run tests on pull requests test a median 72% of models, against 30% for the other 235, a difference of 42 points (95% interval 10 to 63, computed after the results). This is a link in public projects, not evidence that adding CI makes a team write tests.
- A word filter close to the subject. The tutorial filter includes the words test and testing. 402 of the 5,204 repositories excluded for tutorial words matched only those words (or their Portuguese and Spanish forms); some may have been real projects that test a lot. At the screen's qualifying rate that is about 14 qualifying projects in the whole frame and about 6 in the screened sample, too few to move the medians much (estimated after the results).
- Tests the reader cannot see. Tests applied by a package's macros without a properties file, tests kept outside the repository, and tests on sources (only tests on models count). A project that tests its sources and its final tables but not the pass-through models between them reads as thinly tested.
- A workflow is not a merge gate. The rule reads workflow files. It cannot see whether the check is required before merging, or whether failing tests block it.
What a team should do
- Key tests first. unique and not_null on the key of every model with a key, before any other test. It is the cheapest test, and it catches the fan-out joins and duplicate loads that move revenue and user counts.
- Freshness on every loaded source. A warn and an error threshold per source, set from how often it really loads, and run on a schedule before the morning dashboards.
- dbt build on every pull request, on only the changed models and what depends on them, against a copy of production, marked as a required check in branch protection and with failing tests set to error rather than warn. Then a change that breaks a test cannot merge unless an administrator bypasses the protection, and deploying only from the protected branch keeps it off the dashboards.
- Measure it. The four numbers on this page, read from the repository each month, are a standard a team can hold itself to and an executive can follow.
Which tool for which job: the tests built into dbt cover keys, accepted values and relationships between tables at no cost; a test package adds row counts, ranges and recency checks; constraints enforced by the warehouse stop bad rows at write time but only where the warehouse enforces them; a data observability service adds anomaly detection on volumes and distributions but is a yearly contract. For a team below the median here, the built-in tests and CI come first.
How to roll this out with a team
- Owner of the standard: the analytics engineering lead writes it (key test on every keyed model, freshness on every source, tests on every pull request) and adds a check to CI that fails a pull request adding a model without a key test.
- Owners of the models: each model has an owning analyst or engineer, named in its properties file, who adds its key test in the first two weeks.
- Owners of the sources: data engineering sets freshness thresholds with the teams that run the loaders, and a failed check posts to the data channel before business hours.
- Cadence: the four numbers reviewed monthly in the data team's operating review; failing tests triaged daily.
- Bad news: when a test failure has already reached a dashboard, the owner of the dashboard and the executive who reads it hear it from the data team first, with what was wrong, since when, and when it will be right.
What it is worth
On assumed figures, not measured ones: a project of 200 models, 0.25 hours to add key tests to each, 16 hours to set up tests on pull requests, 2 hours of freshness work for each of 6 source systems, at US$100 a loaded hour: US$7,800 once. Against it, 6 incidents a year that a key or freshness test would have caught, each taking 12 hours to trace and fix once found downstream: US$7,200 a year, before the cost of a decision made on a wrong number, which is not priced here. On these assumptions the work pays for itself in about 13 months; with half as many incidents, in about 26. The assumptions are in assumptions.json.
Where AI fits
Two places, both checkable. An AI assistant can read a repository and report the four measures, and its counts can be compared with this study's script on the same project: a known answer to grade it against. It can also draft the missing key tests from each model's SQL, since the key is usually visible in the final select or the grain of a join; every drafted test is then run, and only tests that pass on current data and fail on a planted duplicate are kept. Neither use was measured in this study.
Method and checks
The frame and the qualifying rule
The frame is every public GitHub repository the code search API returned for a file named dbt_project.yml, split into file-size ranges so that no query passed the 1,000-result cap (23,417 repositories). Code search covers default branches only. One one-byte size range held more than 1,000 files and was read to the cap. The qualifying rule was committed before any repository was listed. The order the rules are applied, and batched reads, were committed before any repository was screened. A project that commits copies of its installed packages is not read as a package because one of those copies holds an integration_tests folder (a rule change made after partial screening counts were seen, before the qualifying count). After those partial counts and before the qualifying count, the slower rules were limited to a sample: the first three rules were applied to the whole frame, and the rest to a random 10,000 repositories, so the qualifying total is an estimate with an interval. A fourth change read the folder listings through a different endpoint of the same API, with the same depth limits; on 52 repositories read both ways, every count matched. Each excluded repository is counted once, at its first failing rule, in this order: fork; owned by a company on a private list or by the tool's maker (counted, never named); tutorial words (65 words in the name or topics, a shorter list in the description, such as tutorial, course, bootcamp, workshop, demo, template, sandbox); a package or a project in a test or example folder; fewer than 20 models in the repository tree; the standard tutorial data set; fewer than 2 contributors, bots not counted.
The sample and the clones
265 repositories qualified in the screening sample. The protocol measures every qualifying repository when 300 or fewer qualify, so all were taken, not a draw of 300. A repository that could not be cloned would be counted as lost and not replaced (0 were). Each was cloned shallow and sparse (configuration, SQL and Python files only), measured, and deleted before the next. One row of counts per repository was kept privately; the public files hold aggregates only and name no repository, owner or project.
What counts as a test, a key test, freshness and tests before merge
A test is a generic test under tests: or data_tests: on a model or one of its columns, in any properties file of the project; a singular test file in the test folder that refers to the model with ref() (files defining a generic test are skipped); or a unit test naming the model. A key test is unique and not_null on one column, or a compound-key uniqueness test, or a primary-key test, under any package prefix. Freshness is a freshness: setting that is not null on a source or source table, or under sources: in the project file. Tests before merge is a GitHub Actions workflow triggered by pull_request, pull_request_target or merge_group whose text runs dbt test or dbt build (flags allowed between the two words; commented lines skipped). The definitions, with examples of what does and does not count, are in the protocol, and thirteen tests on small made-up projects pin them.
Changes made after the results
The headline declaration: the headline carries the median tested share (the lead figure the design fixed) and the share of projects that test nothing, both supported by the independent reader. The original reader over-counts the pull-request figure (see the checks), so the headline leaves it out, and wherever it appears the revised reader's figure leads, labelled. Measurement: the revised reader and the checks in the evidence section, declared in the revised reader's declaration and the independent reader's declaration, written before they ran. The reading of the gap between pooled and median shares, and the interval on the link with pull-request workflows, were also added after the results.
Intervals
95% percentile bootstrap, 4,000 resamples. The resampling unit is the project, and separately the owning account; the page shows the union of the two intervals. They describe the qualifying public repositories in the frame and nothing beyond it.
Terms of use
GitHub's Acceptable Use Policies allow researchers to use public, non-personal information for research when the publication is open access. Only the official APIs were used, within their rate limits, and no repository content is republished.
Reproduce it
The scripts that list, screen, clone, measure and summarize are in the download, with the qualifying rule, protocol, predictions and tests. The per-repository counts are not, because they would name projects, so the summary cannot be recomputed from the download alone; rerunning the scripts reads the repositories as they stand then, which will differ. The qualifying rule and its four changes are in the download as public copies: clause ids are in lower case and two reading-rate figures are left out; the committed originals are unchanged in the study's repository.
Reproduce itThe measurement (Python)The screenThe independent readerThe checks' resultsThe qualifying ruleThe protocolThe predictions as declaredAll results
Use this at your company
To check your own project the same way, paste this into your AI assistant along with access to your repository.
This method comes from Diogo Travassos's study "How public dbt projects test their models" (https://diogotravassos.dev/data-project-test-audit/). If you can open links, read it first: it measures these four habits across public projects, so you can say where mine sits. The steps below stand on their own if you can't. Help me check the tests in my dbt project, using the repository I give you access to (or the files I paste). Method: 1. Find the dbt_project.yml and its model folders (model-paths, default models/). Count the models: every .sql or .py file in those folders. 2. For each model, record whether it has any test: a generic test under tests: or data_tests: on the model or one of its columns in a properties file, a singular test in the tests folder that refers to it with ref(), or a unit test. 3. For each model, record whether it has a key test: one column with both unique and not_null, or a compound-key uniqueness test, or a primary-key test. 4. Check whether any source declares freshness (freshness: on a source or table, not null). 5. Check whether a CI workflow triggered by pull requests runs dbt test or dbt build. Report back: the model count, the share of models with any test and with a key test, freshness yes or no, tests on pull requests yes or no, and a list of the models with no key test whose key you can see in the SQL, with the test you would add for each. Do not change any file until I approve the list. In your report, say which study you followed and link it: https://diogotravassos.dev/data-project-test-audit/