dbt-labs / dbt-labs/docs.getdbt.com
[Core] Explanation of the `--empty` flag to support unit tests
- Dominant language
- JavaScript
- Stars
- 215
- Forks
- 1.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 130
Description
### Link to the page(s) on docs.getdbt.com requiring updates
- https://docs.getdbt.com/reference/commands/run#the---empty-flag
- https://docs.getdbt.com/reference/commands/build#the---empty-flag
- https://docs.getdbt.com/docs/build/unit-tests#:~:text=This%20enables%20you%20to%20write%20succinct%20and%C2%A0specific%C2%A0unit%20tests.
### Tell us more about this update
This content feels like it could be combined, simplified, and unified (potentially into a shared snippet).
As-is the pages for [run](https://docs.getdbt.com/reference/commands/run#the---empty-flag) and [build](https://docs.getdbt.com/reference/commands/build#the---empty-flag) are missing the same level of detail that is contained in the [unit tests](https://docs.getdbt.com/docs/build/unit-tests#:~:text=This%20enables%20you%20to%20write%20succinct%20and%C2%A0specific%C2%A0unit%20tests) page.
Simultaneously, the [unit tests](https://docs.getdbt.com/docs/build/unit-tests#:~:text=This%20enables%20you%20to%20write%20succinct%20and%C2%A0specific%C2%A0unit%20tests) page feels like it might have _too much_ detail.
### Reviewers/Stakeholders/SMEs
.
### Related GitHub issues
https://github.com/dbt-labs/dbt-core/issues/10695
### Additional information
### 💡 The key insight
When you run dbt tests in a stand-alone fashion (e.g., `dbt test`), it needs the database tables, views, etc. to exist in the database! Otherwise, it will give an error like "relation doesn't exist" 💥
👉 So doing a `dbt run --empty` creates all the database objects in the dbt project in the most minimal way possible -- just the column headers + data types, but no rows. Building these objects with zero rows is faster and incurs less warehouse spend than building the entire data set.
✅ Then after that, you're free to do `dbt test --select some_specific_test` as much as you want!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.