dbt Analytics Engineering (50 Qs)•Part 1: dbt Core Concepts & Fundamentals (Junior / Entry-Level)
What are the 4 Out-of-the-Box Generic Tests in dbt?
junior LevelCode ExampleTypeScript
In Simple Words: dbt provides 4 built-in schema tests declared in YAML:
unique: Asserts that no two rows have the same value in the specified column (verifies primary key integrity).not_null: Asserts that every row in the column contains a non-null value.accepted_values: Asserts that column values match a predefined list of allowed strings (e.g.['placed', 'shipped', 'delivered', 'returned']).relationships: Asserts referential integrity (foreign key in fact table must exist in dimension table primary key).
yaml
version: 2
models:
- name: fct_orders
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'cancelled']
- name: customer_id
tests:
- relationships:
to: ref('dim_customers')
field: customer_id