dbt Interview Questions

Dan Lee's profile image
Dan LeeData & AI Lead
Last update
dbt Interview Questions

dbt questions show up in every analytics engineering loop and in most data engineering loops where the warehouse is Snowflake, BigQuery or Databricks. Interviewers rarely ask what dbt is. They ask why an incremental model double counts, why CI rebuilt 400 models for a one-line change, or how you would rename a column that three teams depend on.

The weak spots are predictable. Candidates write is_incremental() filters that drop late rows, assume unique_key deduplicates the source, believe a primary_key constraint is enforced on Snowflake, or override generate_schema_name so that every developer writes to the production schema. Each answer below names the trap along with the fix.

The 30 questions are grouped into five areas: models and the DAG, materializations and incremental models, tests and contracts, snapshots and Jinja, and CI with state selection and the Semantic Layer. Behavior matches the dbt docs as of October 2026 (dbt v1.12 and dbt v2), with a version note wherever a feature is recent.

Intermediate30 questions

dbt Interview Questions

Practice questions on building, testing and deploying dbt projects: ref and sources, incremental strategies, tests and contracts, snapshots, macros and state-based CI.

Analytics EngineerData EngineerData AnalystBI EngineerData Platform Engineer

Models, Sources and the DAG

Interviews open here because everything else in dbt depends on it. A model is a select statement in a file, and dbt builds the dependency graph from the ref() and source() calls inside those selects. Once you understand how that graph is built, selection syntax, environments and CI follow from it.

The idea that matters most is that ref() resolves at compile time to a relation in the current target. The same code points at your dev schema on your laptop, a pull request schema in CI and the production schema in the deploy job, which is what makes isolated development possible.

Models, Sources and the DAG

A teammate's model selects from analytics.stg_orders directly instead of {{ ref('stg_orders') }}. It works in production. What breaks, and when?

EasyModels, Sources and the DAG

Sample Answer

Hard-coding the relation removes the edge from the DAG, so dbt no longer knows stg_orders has to build first. On a fresh run the model can execute before its parent and read stale or missing data, and dbt build --select +my_model won't include the parent. It also breaks environments. ref() compiles to the relation for the current target, such as dbt_alice.stg_orders in development or the pull request schema in CI. The hard-coded name always reads production, so a developer who changes stg_orders tests the downstream model against old production data and sees no difference. Lineage in the docs site loses the edge too. Use ref() for models and source() for raw tables.

Learn this in the Data Pipelines and Orchestration course

Materializations and Incremental Models

Materialization questions look like trivia until the follow-ups arrive: why is the dashboard slow, why did the warehouse bill grow, why is revenue double counted. A materialization is a one-word config, and it decides when the SQL runs, what it costs and what can go wrong on a rerun.

Most of the depth is in incremental models. An incremental run executes your select with an extra filter and then applies the result to the existing table with a strategy, so correctness depends on the filter and the strategy agreeing about which rows can change.

Materializations and Incremental Models

When would you choose a view, a table, an incremental model, an ephemeral model, or a materialized view or dynamic table? Give an example for each.

EasyMaterializations and Incremental Models

Sample Answer

The default is view: no storage and always current, but the SQL runs every time someone queries it, so it suits light staging models. table rebuilds from scratch on every run, which is simple and always correct, and fits marts that rebuild in minutes. incremental processes only new or changed rows and pays off on large event or fact tables where a full rebuild is slow or expensive. ephemeral isn't built at all: dbt inlines it as a CTE into its children, so it can't be queried directly, can't be referenced from run-operation and doesn't support contracts. materialized_view lets the platform maintain the result; dbt-snowflake uses dynamic_table instead, with target_lag and snowflake_warehouse configs.

Learn this in the Data Pipelines and Orchestration course

Tests, Unit Tests and Contracts

A green dbt run says the SQL executed. It says nothing about whether the rows are right. Interviewers probe testing because it shows whether you treat data correctness as part of the build, or as something a stakeholder notices on a dashboard.

Keep three layers apart. Data tests check the rows a model produced, unit tests check the model's logic on fixed inputs before it is built, and contracts check the model's shape (column names and types) at build time. Each one catches a different class of bug.

Tests, Unit Tests and Contracts

Add tests to fct_orders that catch duplicated orders, unknown statuses and orphan customer IDs. Where do they go, and what makes a test pass?

EasyTests, Unit Tests and Contracts

Sample Answer

dbt ships four generic data tests: unique, not_null, accepted_values and relationships. You declare them in the model's YAML under data_tests:. The older tests: key still works as an alias, but not both on one resource. Current versions put test inputs such as values, to and field under arguments: and framework options such as severity and where under config:. Each test compiles to a query that selects failing rows, and it passes when that query returns zero rows. dbt test --select fct_orders runs them alone, and dbt build runs them right after the model builds. Setting store_failures: true saves the failing rows to an audit table for debugging.

Text
1models:
2  - name: fct_orders
3    columns:
4      - name: order_id
5        data_tests: [unique, not_null]
6      - name: status
7        data_tests:
8          - accepted_values:
9              arguments:
10                values: ['placed', 'shipped', 'completed', 'returned']
11      - name: customer_id
12        data_tests:
13          - relationships:
14              arguments: {to: ref('dim_customers'), field: customer_id}
Learn this in the Data Pipelines and Orchestration course

Snapshots, Jinja and Macros

Snapshots are dbt's answer to history that the source system throws away, and interviewers use them to check that you understand slowly changing dimensions, not just the config. Jinja and macros come up because every non-trivial project has them, and badly written macros are a common source of slow, unreadable SQL.

For snapshots, the idea that matters is that they record state when they run, not every change. For Jinja, it is that templates render to SQL text before anything executes, and dbt also renders every file at parse time, when no query results exist yet.

Snapshots, Jinja and Macros

The customers table in the app database overwrites a customer's plan in place. Finance needs to know which plan each customer was on when each order was placed. How do you build that with dbt?

MediumSnapshots, Jinja and Macros

Sample Answer

Capture history with a snapshot, which builds a type 2 slowly changing dimension. Since v1.9 snapshots are configured in YAML. On each dbt snapshot run, dbt compares the source with the snapshot table: when a row changed, it closes the current version by setting dbt_valid_to and inserts a new version with dbt_valid_from. Current rows have a null dbt_valid_to unless you set dbt_valid_to_current to a far-future date, which makes range joins simpler. Join orders on order_ts >= dbt_valid_from and before dbt_valid_to (or a null one). hard_deletes: invalidate closes rows deleted at the source, while the default ignore leaves them current forever. Snapshots ignore --full-refresh, because history can't be rebuilt.

Text
1snapshots:
2  - name: customers_snapshot
3    relation: source('app', 'customers')
4    config:
5      schema: snapshots
6      unique_key: customer_id
7      strategy: timestamp
8      updated_at: updated_at
9      hard_deletes: invalidate
Learn this in the Data Pipelines and Orchestration course

CI, State Selection and the Semantic Layer

Once a project has hundreds of models, the questions shift from writing SQL to shipping it safely. Interviewers ask how you test a pull request without rebuilding the warehouse, how you recover a failed production run, and how metric definitions stay consistent across tools.

The key idea is state comparison. dbt can compare your project with the manifest.json from production, build only what changed and what depends on it, and read everything else from production. Get that right and CI takes minutes instead of hours.

CI, State Selection and the Semantic Layer

Your CI job runs dbt build on the whole 600-model project for every pull request and takes 90 minutes. Design a faster CI job.

MediumCI, State Selection and the Semantic Layer

Sample Answer

Run Slim CI. Save manifest.json from the production job and pass its folder as --state. state:modified+ selects nodes whose SQL, configs, macros or contracts changed, plus everything downstream of them. --defer resolves ref() to the production relation for any model that isn't selected and doesn't exist in the CI schema, so a changed model reads its unchanged parents from production instead of rebuilding them. Build into a schema per pull request and drop it when the PR closes. On the dbt platform, CI jobs manage state and deferral for you. Don't point --state at the same target/ folder the run writes to, since dbt overwrites manifest.json while parsing.

Bash
1# prod job: copy target/manifest.json to ./prod-artifacts after each deploy
2dbt deps
3dbt build --select "state:modified+" \
4  --defer --state ./prod-artifacts \
5  --target ci
Learn this in the Data Pipelines and Orchestration course

How to Prepare for dbt Interviews

Build an incremental model, then break it on purpose

Most dbt interviews spend real time on incremental models, and the fastest way to understand them is to watch one fail. Build one, feed it late rows and duplicate keys, and see which strategy handles which case, following Incremental models, then work through Late data and reprocessing.

Know what each materialization costs

Be ready to say when a view becomes too slow, when a table becomes too expensive, and why ephemeral models are hard to debug. Practice putting a number on it: how long the rebuild takes and how often the model is queried. Materializations covers the tradeoffs, and Models and ref covers how ref resolves per environment.

Test at three levels and say which bug each one catches

Interviewers like candidates who separate data tests, unit tests and contracts instead of saying "we added tests". Write one of each for the same model and explain what each would have caught in a real incident. Tests and data contracts covers all three.

Practice snapshots and macros by hand

Write a snapshot config from memory, join a fact to it with valid-from and valid-to ranges, and override generate_schema_name without breaking development schemas. Sources, freshness and snapshots and Project structure, Jinja and macros cover both.

Rehearse the slow and wrong model case

The most common dbt case question is a model that got slow and started returning wrong numbers at the same time. Practice diagnosing it out loud, then explain how Slim CI with state:modified+ and --defer would have caught the bug before it shipped. Use A dbt model that is slow and wrong and CI and deployment for data pipelines.

How Ready Are You for dbt Interviews?

1 / 6
Models and ref

A model hard-codes analytics.stg_orders instead of calling ref(). What is the main risk?

Frequently Asked Questions

Is dbt asked in data engineering interviews?

Often, wherever the team transforms data inside a warehouse such as Snowflake, BigQuery or Databricks. Analytics engineering loops center on it. Data engineering loops usually include a dbt section next to orchestration and pipeline design, with questions about incremental models, testing and CI. Platform roles get more of the deployment side: state selection, environments, grants and how dbt fits with an orchestrator. Expect scenarios rather than definitions.

What level of dbt do I need for an analytics engineer interview?

You should be able to build a layered project from scratch, choose materializations and defend the choice, write a correct incremental model including late data, test models at three levels, snapshot a mutable table, and write a simple macro. Senior candidates are also asked about Slim CI, model contracts and versions, and the Semantic Layer. Knowing every config key matters less than explaining what a run does to the warehouse.

How long does it take to prepare for dbt interview questions?

With solid SQL and some dbt use at work, one to two weeks of focused practice is usually enough. Spend most of it on incremental models, tests and snapshots, and a few days on CI and project structure. Without hands-on experience, plan for three to four weeks and build a small project end to end on a free warehouse tier, because interviewers can tell quickly whether you have run dbt yourself.

Should I learn dbt v1 or dbt v2 for interviews?

The concepts are the same, so learn them on whichever version you can run. As of October 2026, v1.12 is the latest v1 release and dbt v2 is generally available. v2 parses projects faster, rejects misspelled configs and unknown YAML keys at parse time, removes the old --models flag in favor of --select, and adds dbt freshness for models. Mention these if asked, but interview questions focus on modeling, testing and deployment.

Do I need to know Jinja for dbt interviews?

Enough to read and write the common patterns: ref, source, config, is_incremental(), {{ this }}, loops, if blocks, simple macros and run_query guarded by execute. You won't be asked to write a complex package. You will be asked why a macro fails at parse time, or how a generate_schema_name override can make developers overwrite production. Reading compiled SQL in target/compiled/ is the habit that makes Jinja debugging easy.

What is the difference between dbt and Airflow?

They solve different problems and usually work together. dbt transforms data already in the warehouse: it compiles SQL models, orders them by their refs, materializes them, and tests the results. Airflow is a general orchestrator that schedules and runs tasks of any kind, such as extracts, API calls, dbt invocations and file moves, with retries and dependencies between them. A typical setup has Airflow trigger the extract, then dbt build, then downstream jobs.

Dan Lee's profile image

Written by

Dan Lee

Data & AI Lead

Dan is a seasoned data scientist and ML coach with 10+ years of experience at Google, PayPal, and startups. He has helped candidates land top-paying roles and offers personalized guidance to accelerate your data career.

Connect on LinkedIn