Practice: dbt problems
Practice tracks: PySpark & SQL (84) · dbt (25) · Airflow (10) · Python (52)
25 free dbt interview problems: write models with source() and ref(), Jinja, macros, data tests and incremental models, graded on hidden tests.
Sources & staging
source(), renaming and casting, null-safe filters and deduplicating change data.
- Staging Model for Raw Orders · Easy
- Latest Version of Each Customer · Medium
Refs & marts
ref(), joining staging models into one row per entity without fan-out.
- Customer Order Summary Mart · Medium
Jinja, vars & packages
loops, if blocks, var(), target and dbt_utils macros.
- Daily Revenue for a Reporting Window · Easy
- Pivot Payments with a Jinja Loop · Medium
- Smaller Builds in Development · Medium
- Surrogate Key for Order Lines · Medium
Macros
reusable SQL with arguments and defaults.
Data tests
singular and generic tests, and writing schema.yml tests that catch broken data without false alarms.
- Data Test: Refunds Larger Than the Order · Easy
- Write the Tests for an Orders Model · Easy
- A Reusable not_negative Test · Medium
- Orphaned Rows: a relationships Test · Medium
- Catch Orphaned and Invalid Payments · Medium
- Test the Grain of a Daily Fact Table · Medium
- Tests That Know What to Ignore · Hard
- Test an SCD Type 2 History Table · Hard
Incremental models
is_incremental(), {{ this }}, unique_key, strategies, late data and reruns over several days.
- Append-Only Incremental Events · Medium
- Rerun a Day Without Duplicates · Medium
- Incremental Upserts with unique_key · Hard
- Late Data: Incremental with a Lookback · Hard
- Incremental Model with a Composite Key · Hard
- Daily Counts That Survive Late Events · Hard
Snapshots
SCD Type 2 history with the timestamp and check strategies and hard deletes, over several runs.