Hey @oferk83, welcome!
dbt is typically used with analytical data warehouses like Redshift, Snowflake, and BigQuery. In these databases, column constraints are usually either unsupported or unenforced by the database. For this reason, dbt has the ability to assert data constraints without actually materializing them in the database.
When you run dbt test
, dbt will generate SQL queries that assert the validity of the tests that you’ve defined for your models. You can check out the definition of the relationships schema test in the dbt repo. The unique
, not_null
, and other tests are all defined similarly.
With this paradigm, you can also test other attributes of your models that can’t be expressed as column constraints in your database. Check out some examples of those in the dbt-utils repo.