The dbt questions to prepare for an analytics engineering interview: ref(), materializations, incremental models, tests, snapshots and CI, with answers.
Most dbt interview questions check whether you understand what dbt does when it runs, not whether you memorised commands. Expect to explain how ref() builds the dependency graph, when a model should be a view, a table or incremental, how a test fails, and how you would stop a change from breaking production. Below are twelve questions grouped by topic, each with what the interviewer is checking and a short answer to adapt.
What the interview covers
Formats differ by employer, so ask the recruiter whether the technical round is live SQL, a project walkthrough or a take-home. The content is more predictable. dbt Labs' Analytics Engineering certification covers seven areas: developing and optimising models, model governance, debugging modelling errors, troubleshooting pipelines, tests, external dependencies such as source freshness, and dbt state. The questions below follow that map.
Fundamentals
1. What is dbt, and what doesn't it do?
Checking: whether you can place it in the stack. dbt is the transformation step: you write select statements with Jinja, dbt compiles them and builds the results inside your warehouse. It does not load raw data; the dbt docs describe sources as data your extract and load tools have already put in the warehouse.
2. What do `ref()` and `source()` do?
Checking: the DAG. ref() compiles to the full name of another model and records the dependency, which is how dbt builds its DAG and works out run order. Because it interpolates the schema, the same code can build into dev or production. source() does the same for raw tables and adds the source to the DAG, so lineage and selectors like source:jaffle_shop+ work. Tests and freshness checks are declared on the source in YAML. A senior detail: dbt finds dependencies while parsing, so a ref() in an untaken if branch can be missed; a depends_on SQL comment outside the branch fixes it.
3. Which materialization would you choose, and why?
Checking: cost and speed judgment. The default is a view: nothing stored, always current, slow when views stack. Tables are fast to query and slow to rebuild. Incremental models process only new rows. Ephemeral models are inlined as CTEs and can't be queried directly. Materialized views are often refreshed by the platform itself, though not every warehouse supports them, and dbt-snowflake uses Dynamic Tables instead. The strongest answer is dbt's rule of thumb: start with a view, make it a table when it is too slow to query, and make it incremental only when the table is too slow to build.
4. How would you structure a dbt project?
Checking: whether you have maintained one. dbt's guide uses three layers. Staging models map one-to-one to source tables, rename and cast columns, avoid joins and aggregations, and are the only place source() appears; dbt recommends building them as views. Intermediate models (int_orders_pivoted style) prepare staging models for marts, and dbt generally recommends keeping them out of the main production schema, for example as ephemeral models or views in a separate schema. Marts are named by entity, such as customers or orders, and built as tables or incremental models.
5. When would you write a macro?
Checking: restraint as much as Jinja skill. A macro is reusable Jinja, like a function; a cents-to-dollars conversion used in ten models is a good candidate. Check dbt-utils before writing your own. dbt's docs advise favouring readability over DRY-ness, so say when you chose not to write one.
Incremental models
6. Walk me through an incremental model.
Checking: the first run, later runs and a full refresh. A worked example, with the config in the model's YAML:
models:
- name: fct_events
config:
materialized: incremental
unique_key: event_idIn the model's SQL, the filter sits inside an if is_incremental() block and reads from this. On an incremental run, the select dbt compiles looks like this:
select event_id, user_id, event_type, event_at
from analytics.stg_app__events
where event_at >= (select coalesce(max(event_at), '1900-01-01') from analytics.fct_events)What a strong answer covers:
- is_incremental() is true only when the table already exists, the model is configured as incremental and --full-refresh was not passed. On the first run the where clause is left out and the whole history loads, so the SQL must work both ways.
- this is the existing target table (analytics.fct_events above), so the filter reads its newest timestamp.
- >= reprocesses rows at that timestamp, and unique_key makes the overlap safe: matching keys are updated, new keys inserted. Without a unique_key, most adapters only append, so the same overlap creates duplicates.
- The weakness: an event that arrives late with an older event_at is never picked up. Widen the filter with a lookback window of a few days, for example filtering on the upstream table's timestamp with a fixed-day cutoff as dbt's docs do when limiting an upstream scan, and let the key handle the re-read rows.
Likely follow-ups: the key must not contain nulls; --full-refresh drops and rebuilds the table; and when the source adds a column, on_schema_change decides what happens. The default, ignore, leaves new columns out; append_new_columns adds them, sync_all_columns also removes dropped ones, and fail stops the run. None of them backfill existing rows.
Testing and history
7. How do dbt tests work?
Checking: the mechanism. A data test returns the rows that break a rule; zero rows means it passes. Four generic tests ship with dbt: unique, not_null, accepted_values and relationships. Singular tests are one-off SQL files. Under dbt build, a failing test skips the models downstream of it unless its severity is set to warn. Say which tests you put on every primary key.
8. What is the difference between data tests and unit tests?
Checking: whether you are current. Unit tests arrived in dbt 1.8. They run before a model is built, on hand-written input rows (given) and expected output (expect), to check logic such as a case statement. Data tests check real data after the build. dbt recommends running unit tests in development and CI only, since their inputs never change.
9. When would you use a snapshot?
Checking: slowly changing dimensions. A snapshot records how rows in a mutable table change, as type-2 history with dbt_valid_from and dbt_valid_to. Use the timestamp strategy when the source has a reliable updated_at, and the check strategy, comparing listed columns, when it does not. Snapshots ignore --full-refresh and cannot be rebuilt, so keep them in their own schema.
Running dbt in production
10. A dbt run failed overnight. What do you do?
Checking: method. Read the error, open the failing model's compiled SQL under target/, and run it in the warehouse to see whether the data or the logic is wrong. run_results.json records what ran and failed. Rerun it and its downstream models with --select model_name+. Close with what would catch it earlier: a test, a freshness check or an alert.
11. How would you set up CI for a dbt project?
Checking: whether you avoid rebuilding everything per pull request. Describe "slim CI": dbt build --select state:modified+ --defer --state <prod-artifacts>. state:modified compares the project with production's manifest.json, the + adds downstream models, and --defer points unbuilt upstream models at production.
12. Tell me about a data incident you handled.
Checking: ownership and communication. Pick a real one, such as a duplicated revenue number or a late source. Cover who noticed, how you found the cause, how you told stakeholders, and what test or process you added afterwards. Keep each part of situation, task, action, result short.
A short preparation plan
Build a small dbt project on a public dataset: a source, staging models, a mart, tests, a snapshot and an incremental model. Then break it and fix it. Practise questions 3, 6 and 10 aloud, since they show judgment best. For the SQL side, see our SQL query interview questions; if the stack runs on Databricks, our Databricks coding interview questions.
To rehearse out loud, Verve AI's Mock Interview has an AI recruiter ask questions from banks including Data & Analytics, then gives you a scored performance report.
Sources
- Analytics Engineering certification: seven topic areas: https://www.getdbt.com/certifications/analytics-engineer-certification-exam
- Sources are data loaded by extract and load tools; source() benefits; freshness configuration: https://docs.getdbt.com/docs/build/sources
- ref() compiles to the relation name, interpolates the schema, builds the DAG; parse-time dependency caveat and depends_on comment: https://docs.getdbt.com/reference/dbt-jinja-functions/ref
- Five materializations, view as default, trade-offs, Snowflake Dynamic Tables: https://docs.getdbt.com/docs/build/materializations
- Staging layer rules (one-to-one, no joins or aggregations, only place for source(), views): https://docs.getdbt.com/best-practices/how-we-structure/2-staging
- Intermediate layer naming and generally keeping it out of the main production schema: https://docs.getdbt.com/best-practices/how-we-structure/3-intermediate
- Marts named by entity, tables or incremental, "start with a view" rule of thumb: https://docs.getdbt.com/best-practices/how-we-structure/4-marts
- Macros, dbt-utils, favour readability over DRY-ness: https://docs.getdbt.com/docs/build/jinja-macros
- is_incremental() conditions, this, unique_key behaviour, append-only default, null keys, full refresh, on_schema_change options, fixed-day filter limiting an upstream scan: https://docs.getdbt.com/docs/build/incremental-models
- Data tests return failing rows, four generic tests, singular tests: https://docs.getdbt.com/docs/build/data-tests
- dbt build order and test failures skipping downstream nodes, severity warn: https://docs.getdbt.com/reference/commands/build
- Unit tests introduced in dbt 1.8, given/expect, run in development and CI: https://docs.getdbt.com/docs/build/unit-tests
- Snapshots as type-2 SCD, timestamp and check strategies, meta columns, ignore full refresh, separate schema: https://docs.getdbt.com/docs/build/snapshots
- run_results.json and other artifacts written to target/: https://docs.getdbt.com/reference/artifacts/dbt-artifacts
- state:modified, --defer and --state for slim CI: https://docs.getdbt.com/reference/node-selection/state-selection
- Verve AI Mock Interview (AI recruiter, Data & Analytics bank, scored report): https://docs.vervecopilot.com/features/mock-interview
Ryan
CEO of Verve AI







