Skip to content

Diogo TravassosData leadership · Analytics · Decision-making

Public data

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.

63 of the 265 projects (24%) test no model; the median project tests 32% of its models

Projects in each band of the share of their models with any test (%)

  1. 63none
  2. 21<10
  3. 1910s
  4. 2020s
  5. 2230smedian
  6. 1840s
  7. 1550s
  8. 1160s
  9. 1570s
  10. 1280s
  11. 1890s
  12. 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 checkedKey tests14%of models with a key test in the median project (7 to 22%); 34% of projects have noneSource freshness22%of projects declare it (17 to 27%); predicted under 15%, a missTests 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 the 265 projects that meet each of the four measures

Share of projects (95% interval under each bar)

  1. Test half or more of their models38%32 to 45%
  2. Check the key of half or more of their models25%20 to 31%
  3. Declare freshness on a source22%17 to 27%
  4. 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.

Projects by the share of their models with any test and with a key test (colours in the key below): the key-test columns pile up at none.

Any testKey test

Projects by the share of their models with any test and with a key test02040608010063 of 265 projects (24%) have no model with any test.89 of 265 projects (34%) have no model with a key test.none21 of 265 projects (8%) have 1-9% of their models with any test.34 of 265 projects (13%) have 1-9% of their models with a key test.<1019 of 265 projects (7%) have 10-19% of their models with any test.23 of 265 projects (9%) have 10-19% of their models with a key test.10s20 of 265 projects (8%) have 20-29% of their models with any test.24 of 265 projects (9%) have 20-29% of their models with a key test.20s22 of 265 projects (8%) have 30-39% of their models with any test.16 of 265 projects (6%) have 30-39% of their models with a key test.30s18 of 265 projects (7%) have 40-49% of their models with any test.12 of 265 projects (5%) have 40-49% of their models with a key test.40s15 of 265 projects (6%) have 50-59% of their models with any test.14 of 265 projects (5%) have 50-59% of their models with a key test.50s11 of 265 projects (4%) have 60-69% of their models with any test.14 of 265 projects (5%) have 60-69% of their models with a key test.60s15 of 265 projects (6%) have 70-79% of their models with any test.14 of 265 projects (5%) have 70-79% of their models with a key test.70s12 of 265 projects (5%) have 80-89% of their models with any test.9 of 265 projects (3%) have 80-89% of their models with a key test.80s18 of 265 projects (7%) have 90-99% of their models with any test.10 of 265 projects (4%) have 90-99% of their models with a key test.90s31 of 265 projects (12%) have every model with any test.6 of 265 projects (2%) have every model with a key test.allShare of the project's models (%)Projects
Show the data
Share of the project's modelsProjects, any testProjects, key test
None6389
1-9%2134
10-19%1923
20-29%2024
30-39%2216
40-49%1812
50-59%1514
60-69%1114
70-79%1514
80-89%129
90-99%1810
All316
Total265265

Counts of projects; download the rounded shares as distribution.json.

Every measure, with its interval

MeasureValue95% intervalPrediction made before measuring
Median project: share of models with any test32%26 to 42%held
All models pooled: share with any test49%37 to 60%
Projects with no test on any model24%18 to 30%held
Projects with every model tested12%8 to 16%
Median project: share of models with a key test14%7 to 22%
All models pooled: share with a key test38%25 to 49%held
Projects with no key test at all34%28 to 40%
Projects declaring source freshness22%17 to 27%missed
Projects running tests on pull requests11%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 Actions28%22 to 33%
Projects with another CI system's file that runs tests1%0 to 2%
Projects with at least one unit test7%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.

From every repository to the sample

Step, each repository counted once at its first failing ruleRepositories
Repositories holding a dbt project file23,417
Excluded: Owned by a company this site does not name, or by the tool's maker284
Excluded: Tutorial, course, demo or template words in the name, topics or description5,204
Passed the first three rules17,929
A random 10,000 of the 23,417 were read in full:
Of those, passed the first three rules7,672
Excluded: A package (holds an integration_tests project) or a project inside a test or example folder349
Excluded: Fewer than 20 models6,394
Excluded: Built on the standard tutorial data set1
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 sample265
Estimated qualifying in the whole frame (95% interval)619 (550 to 697)
Taken for measurement (all of them)265
Measured265

The predictions

The expected finding, its opposite and six predictions were committed before any project was measured.

Declared before any project was measuredResultVerdict
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% withoutheld

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

What a team should do

  1. 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.
  2. 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.
  3. 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.
  4. 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

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.

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/