Skip to main content
InterviewHubPRO
Section Overview
Q7

Question 7 of 50

Part 1: dbt Core Concepts & Fundamentals (Junior / Entry-Level)

14%
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:

  1. unique: Asserts that no two rows have the same value in the specified column (verifies primary key integrity).
  2. not_null: Asserts that every row in the column contains a non-null value.
  3. accepted_values: Asserts that column values match a predefined list of allowed strings (e.g. ['placed', 'shipped', 'delivered', 'returned']).
  4. 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