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.
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.
Raw tables are loaded by an EL tool into a raw database. How do you declare them in dbt, and how do you get alerted when the orders table stops updating?
EasyModels, Sources and the DAG
Sample Answer
Declare them as sources in YAML and read them with {{ source('shop', 'orders') }}. That gives raw tables nodes in the DAG, one place to change database and schema names, and somewhere to attach tests and freshness rules. Freshness compares the newest value of loaded_at_field (or the result of loaded_at_query, added in v1.10) with the current time and warns or errors past your thresholds. freshness moved under config: in v1.9 and loaded_at_field followed in v1.10, and each threshold needs both count and period. Run dbt source freshness, or dbt freshness in dbt v2, which also covers models. A filter limits the freshness query on large tables.
What is the difference between dbt run and dbt build? A unique test on stg_orders fails during dbt build. What happens to fct_orders downstream, and how do you make a test non-blocking?
MediumModels, Sources and the DAG
Sample Answer
dbt run only materializes models. dbt build runs models, data tests, unit tests, snapshots and seeds (plus user-defined functions from v1.11) in DAG order, testing each node right after it builds. A failing test blocks its children, so fct_orders is reported as SKIP and keeps yesterday's data. That is the point: bad rows never reach the mart. With dbt run followed by dbt test, the mart would already contain the duplicates when the test failed. To make a test advisory, set severity: warn, or keep it an error with a threshold such as error_if: ">100" so a handful of failures only warns. Unit tests run before their model is materialized, so a failing one stops the build of that model.
Write selection commands for: (a) a changed staging model and everything downstream, (b) a mart and all its ancestors, (c) everything tagged finance except models under models/marts/legacy, (d) a model, its descendants, and every ancestor those descendants need.
MediumModels, Sources and the DAG
Sample Answer
A + after a node selects it and all descendants, a + before it selects it and all ancestors, and a number limits the depth (2+fct_revenue stops at grandparents). tag:, path:, source: and test_type: are selection methods, and --exclude removes nodes after selection. Space-separated selectors form a union and comma-separated ones an intersection, as in tag:finance,config.materialized:incremental. @ selects the node, its descendants and all ancestors of those descendants, which matters in CI when a child also depends on models you didn't touch. Quote selectors so the shell leaves them alone. In dbt v2 the old --models and -m flags raise an error, so use --select or -s.
Your project has 300 models in one flat folder, marts read raw sources directly, and the same amount_cents / 100 logic appears in 40 places. How would you restructure it?
MediumModels, Sources and the DAG
Sample Answer
Split it into staging, intermediate and marts layers. Staging models map one-to-one to source tables and are the only models that call source(): they rename, cast, convert units (cents to dollars, once) and do light cleaning, with no joins, and they're usually views. Intermediate models hold reusable joins and business logic that isn't a final output. Marts are the facts and dimensions people query, built as tables or incremental models. Set materializations and schemas per folder in dbt_project.yml so new models inherit them. The rule interviewers listen for is direction: data flows from sources to staging to intermediate to marts, and a mart that reads source() directly skips every cleaning step.
A developer sets +schema: marts on the marts folder, and in production the tables land in analytics_marts instead of marts. Someone proposes a generate_schema_name macro that simply returns the custom schema. What goes wrong, and what do you write instead?
HardModels, Sources and the DAG
Sample Answer
dbt's default generate_schema_name returns the target schema, an underscore and the custom schema, so analytics plus marts gives analytics_marts. That's deliberate. Without the target prefix, every developer's dev run and every CI run would write into the same marts schema and overwrite each other, and a half-finished model could replace a production table. That is exactly what returning the custom schema unconditionally causes. Use the bare custom schema only in production and keep the default elsewhere. dbt ships generate_schema_name_for_env, which does this when target.name == 'prod', and the macro below spells out the same logic. Make sure the production job's target is named prod, and note dbt ignores this override inside installed packages.
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.
Write an incremental model fct_events that loads only new events from stg_events, and explain what happens on the first run and with --full-refresh.
MediumMaterializations and Incremental Models
Sample Answer
is_incremental() is true only when the target table already exists, the model is materialized as incremental, and --full-refresh wasn't passed. On the first run it's false, so the filter disappears and dbt builds the whole table. On later runs {{ this }} resolves to the existing table, and the filter selects events at or after the newest one already loaded. Use >= rather than >, because rows sharing the boundary timestamp can arrive after the last run, and unique_key makes those overlapping rows update instead of inserting twice. --full-refresh drops and rebuilds from all data, while full_refresh: false protects a huge table from an accidental rebuild. The SQL must be valid with and without the filter.
The incremental model above undercounts mobile events. Mobile clients buffer events offline and upload them up to three days late, keeping the original event_ts. Why are they lost, and how do you fix it?
HardMaterializations and Incremental Models
Sample Answer
The filter uses the table's own high-water mark. Once a desktop event from 10:00 today is loaded, a mobile event stamped 18:00 yesterday that arrives tonight is below max(event_ts) and never passes the filter. A full refresh would find it, so the bug hides until someone reconciles counts. There are two fixes. Filter on arrival time instead of event time, for example a _loaded_at column set by the loader, which only increases. Or reprocess a lookback window of three days with unique_key set, so re-read rows update rather than duplicate. Measure real lateness before picking the window. The price of a lookback is rescanning those days every run, and incremental_predicates can limit how much of the target the merge scans.
An incremental model with unique_key='order_id' and the default merge strategy on Snowflake starts failing with a nondeterministic merge error after the source begins sending duplicate order_id rows in one batch. Explain the error and two ways to fix it.
MediumMaterializations and Incremental Models
Sample Answer
unique_key tells dbt how to match new rows to existing ones. It doesn't deduplicate the new batch. With merge, which is dbt-snowflake's default, two source rows matching one target row leave Snowflake unable to pick a winner, and with ERROR_ON_NONDETERMINISTIC_MERGE at its default the MERGE fails. The proper fix is deduplicating inside the model, keeping the latest version per key with qualify row_number() over (partition by order_id order by updated_at desc) = 1, plus a unique test on the staging model. dbt's Snowflake docs also suggest delete+insert, which deletes matching keys and inserts the batch. It won't error, but both duplicates land in the table. Key columns must also be non-null, or matches fail and rows duplicate.
Compare append, merge, delete+insert, insert_overwrite and microbatch on Snowflake and BigQuery. Which would you pick for a 5 TB date-partitioned event table where whole days are restated?
HardMaterializations and Incremental Models
Sample Answer
append inserts with no duplicate check. merge matches on unique_key to update or insert, behaves like append without a key, and is dbt-snowflake's default. delete+insert deletes target rows whose keys appear in the batch, then inserts it. insert_overwrite differs by platform. On BigQuery it replaces only the partitions the batch touches; on Snowflake it truncates and reinserts the entire table, since dbt-snowflake has no partition-based overwrite. microbatch processes time batches independently and uses delete+insert on Snowflake and insert_overwrite on BigQuery under the hood. For whole-day restatements, use insert_overwrite with partition_by on BigQuery. On Snowflake, use microbatch or delete+insert keyed on the date, and never insert_overwrite, which would rewrite all 5 TB.
Rewrite a daily event model as a microbatch incremental model that reprocesses three days for late data, and explain how you backfill September.
MediumMaterializations and Incremental Models
Sample Answer
Microbatch (dbt v1.9+) splits work into batches by event_time, starting at begin, each batch_size long (hour, day, month or year). You write no is_incremental() block. dbt filters every upstream ref or source that has its own event_time config to the batch's window, so stg_events needs event_time: event_ts too, or every batch scans all of it. lookback (default 1) reprocesses that many earlier batches each run to catch late rows. Batches are replaced independently, so dbt retry reruns only the failed ones. Backfill with --event-time-start "2026-09-01" --event-time-end "2026-10-01". Both flags must be passed together, and all times are treated as UTC.
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.
Finance says no order may ever have refunds larger than its amount. Write a test for that rule, and explain when a singular test is a better fit than a generic one.
EasyTests, Unit Tests and Contracts
Sample Answer
A singular test is a .sql file in tests/ holding one select that returns the rows breaking the rule. The file name is the test name, and the test passes when the query returns nothing. Leave out the trailing semicolon, which can make it fail. Singular tests suit one-off business rules that span several models, like this one. When the same rule applies to many columns or models, write a generic test instead: a {% test %} block taking model and column_name that you attach in YAML anywhere. While a new rule still has known violations, set severity: warn in a config() block at the top of the file, then switch it to an error once the backlog is fixed.
SQL
1-- tests/assert_refunds_not_above_order_amount.sql2select3 o.order_id,4 o.amount,5sum(r.refund_amount)as total_refunded
6from {{ ref('fct_orders') }} o
7join {{ ref('fct_refunds') }} r on r.order_id = o.order_id
8groupby o.order_id, o.amount
9havingsum(r.refund_amount)> o.amount
A model labels customers new, returning or lapsed with a long case when on order dates. Production data hasn't hit most edge cases yet. How do you test the logic without waiting for real data?
MediumTests, Unit Tests and Contracts
Sample Answer
Use a unit test (dbt v1.8+). It runs the model's SQL against small mock inputs written in YAML and compares the output with the rows you expect, before the model is materialized. You list only the columns the logic uses. Every ref or source the model reads must appear as an input, and the model's direct parents must exist in the warehouse, which dbt run --empty can satisfy cheaply. Put current_date behind a var and pin it with overrides, or the test changes meaning every day. Run unit tests in development and CI with dbt test --select test_type:unit, not in production, since static inputs prove nothing new there. For incremental models, override is_incremental to test both branches.
Another team reads your dim_customers. You enforce a contract with a primary_key constraint on customer_id on Snowflake. Does that stop duplicate customer IDs? What does the contract actually guarantee?
MediumTests, Unit Tests and Contracts
Sample Answer
No. On Snowflake only not_null is enforced. primary_key, unique and foreign_key are created as metadata the platform doesn't check, and check isn't supported, so dbt skips it with a warning. With contract: {enforced: true}, every column must declare a data_type, and dbt runs a preflight check that the query returns exactly those column names and types before it builds. A mismatch fails the model, so a renamed or retyped column can't ship unnoticed. Constraints apply to table and incremental models, views get names and types only, and ephemeral models don't support contracts. Keep a unique data test on customer_id to catch duplicate rows.
Three teams query your contracted fct_orders. You need to rename amount to amount_usd. How does dbt catch the breaking change in CI, and how do you roll it out without breaking those teams?
HardTests, Unit Tests and Contracts
Sample Answer
When a contracted model is compared with production state, dbt treats removing a column, changing a column's data_type or removing a constraint as a breaking change. In CI, state:modified picks up the model and dbt raises a contract error instead of shipping the rename. Model versions handle the rollout. Add a versions: block with a v: 2 that excludes amount and adds amount_usd, and keep latest_version: 1 so unpinned refs still resolve to v1 while consumers migrate. Consumers can test with ref('fct_orders', v=2). Set a deprecation_date on v1 so dbt warns everyone still using it, then bump latest_version and delete v1 after that date. Use access: public only for models other teams or projects may reference.
Data tests on a 2-billion-row fct_events table now take 25 minutes of every build. How do you cut that without losing coverage that matters?
MediumTests, Unit Tests and Contracts
Sample Answer
Scope the tests to the data that can change. The where config adds a filter to a test's query, so a unique test on event_id can check only the last few days the incremental run touched, with something like where: "event_date >= dateadd(day, -3, current_date)". Run the full-table versions on a weekly job. Push cheap integrity checks upstream to staging models, where volumes are smaller. For noisy checks, use severity: warn with warn_if and error_if thresholds rather than deleting them, and limit caps how many failing rows a test returns. Check what each test compiles to: relationships against a huge dimension is a big anti-join, and on Snowflake an enforced not_null constraint can replace a not_null test.
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.
A snapshot using the timestamp strategy misses plan changes that finance can see in the app's audit log. Give the possible causes, and explain how you choose between timestamp and check.
HardSnapshots, Jinja and Macros
Sample Answer
Three causes are common. The app updates plan without touching updated_at, through a bulk fix or a code path that skips the timestamp, so the timestamp strategy sees no change. The row changed several times between runs: snapshots capture the state at run time, so a daily snapshot keeps only the last of three changes made that day. Or unique_key isn't actually unique, which corrupts matching. The check strategy with check_cols: ['plan', 'status'] compares values, so it catches changes without a reliable timestamp, at the cost of comparing columns on every run, and check_cols: all also fires on columns nobody cares about. Prefer timestamp when updated_at is trustworthy. To keep every intermediate change, use log-based CDC from the database rather than snapshots.
Twenty models convert cents to dollars with slightly different rounding. Write a macro for the conversion, and explain what it compiles to.
MediumSnapshots, Jinja and Macros
Sample Answer
A macro is a Jinja function in macros/ that returns text. dbt renders it while compiling the model, so stg_payments compiles to plain SQL containing round(amount_cents / 100.0, 2), and the warehouse never sees any Jinja. When something looks wrong, read the output under target/compiled/ or run dbt compile --select stg_payments. Pass column names as strings, give optional arguments defaults, and use whitespace control ({%- and -%}) to keep the compiled SQL readable. The trap is macro-izing everything. An expression used twice is clearer inline, and deeply nested macros make compiled SQL hard to debug. Check dbt_utils before writing a helper that probably exists already.
A model pivots payments into one column per payment method by querying the distinct methods with run_query. dbt fails while parsing the project with 'None' has no attribute 'columns'. Why, and how do you fix it?
HardSnapshots, Jinja and Macros
Sample Answer
dbt renders each file during parsing as well as during execution. Parsing builds the manifest and the DAG without running SQL, so execute is false, run_query returns None, and calling .columns on it fails. Guard any code that reads query results with execute, as an {% if execute %} block or an inline if execute else, and give it a harmless default for parse time. Mind the side effects too. execute is also true during dbt compile, so this query runs on every compile, and each new payment method silently adds a column, which breaks a contract or any downstream select *. dbt_utils.get_column_values wraps the same pattern. If the set of values rarely changes, a hard-coded list or a seed is easier to review.
SQL
1{%set methods_query %}
2selectdistinct payment_method from {{ ref('stg_payments') }} orderby13{% endset %}
4{%set results = run_query(methods_query)%}
5{# results is None while dbt parses the project #}6{%set methods = results.columns[0].values()ifexecuteelse[]%}
78select order_id
9{%for m in methods %}
10,sum(casewhen payment_method ='{{ m }}'then amount end)as {{ m }}_amount
11{% endfor %}
12from {{ ref('stg_payments') }}
13groupby1
Your project uses dbt_utils, and a teammate's laptop compiles different SQL than CI does. How are packages installed and pinned, and what probably went wrong?
EasySnapshots, Jinja and Macros
Sample Answer
Packages are declared in packages.yml (or dependencies.yml, which can also hold cross-project dependencies but doesn't render Jinja on dbt v1) and installed into dbt_packages/ by dbt deps. Hub packages need a version, either exact or a range such as [">=1.3.0", "<2.0.0"]. dbt deps writes package-lock.yml, pinning the exact release each range resolved to, and later dbt deps runs install from the lock file until the package spec changes. If the lock file isn't committed, or someone ran dbt deps --upgrade, two machines can resolve the same range to different releases and compile different SQL. Commit package-lock.yml, upgrade on purpose, and read the changelog before a major version bump.
After every production run, analysts lose SELECT on the tables dbt rebuilt, and someone has to re-grant by hand. Why does this happen, and how do you fix it inside dbt?
MediumSnapshots, Jinja and Macros
Sample Answer
A table model is rebuilt by replacing the object, and on Snowflake a replaced table doesn't keep the old object's grants unless they are copied, which dbt-snowflake controls with its copy_grants config. The durable fix is the grants config. After a model, seed or snapshot builds, dbt makes the grants on it match the config exactly, issuing grant and revoke statements as needed, and it only manages grants on nodes that have the config. Set it per folder in dbt_project.yml, and use +select in a model to add grantees instead of replacing the folder's list. Grants on objects other than the node itself, such as Snowflake future grants on a schema, still belong in hooks or in Snowflake.
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 deploy2dbt deps
3dbt build --select "state:modified+"\4 --defer --state ./prod-artifacts \5 --target ci
After a change to a macro used in many configs, CI's state:modified+ selects 450 of 600 models. On another pull request it selects everything because a config uses target.name. Explain both, and how you narrow the selection.
HardCI, State Selection and the Semantic Layer
Sample Answer
A model counts as modified when its body, its configs or any macro it depends on changes, including macros called by other macros, so editing a widely used macro legitimately marks hundreds of models. Configs that render differently per environment, such as a schema or warehouse picked with target.name, produce different values in CI than in the production manifest, so dbt sees a config change on every model that uses them. Since v1.9, setting the state_modified_compare_more_unrendered_values flag to true compares unrendered config values and removes those false positives, but the state manifest has to be regenerated with the flag on. To narrow on purpose, use subselectors such as state:modified.body, state:modified.configs or state:modified.contract.
The nightly dbt build fails at model 380 of 600 because of a warehouse timeout. How do you resume, and what has to be true for that to be safe?
EasyCI, State Selection and the Semantic Layer
Sample Answer
Run dbt retry. It reads run_results.json from the failed invocation and re-executes from the point of failure: the errored node and everything skipped because of it, without rebuilding the 379 models that succeeded. It works for build, run, test, seed, snapshot and a few other commands, and does nothing after a successful run. If nothing ran before the failure, as with a connection error at startup, there's nothing to resume, so rerun the job. Safety comes from idempotent models. A table rebuild, or a merge on a real unique_key, can run twice without duplicating rows, while an append-only incremental model may insert a batch twice. For microbatch models, dbt retry reruns only the failed batches.
An hourly production job rebuilds every model, although usually only one of ten sources received new data. How do you build only what has fresh data?
MediumCI, State Selection and the Semantic Layer
Sample Answer
Use source freshness as a selector. dbt source freshness writes sources.json with the latest load time it found for each source. Keep the previous run's sources.json in the state directory, and source_status:fresher+ then selects sources whose data is newer than last time, plus everything downstream. The job runs freshness first, then builds that selection, and models fed by unchanged sources are skipped. Each source needs a loaded_at_field or loaded_at_query, or warehouse metadata where the adapter supports it, so dbt can tell when it last changed. Watch models that join a fresh source to a stale one: they rebuild with partial new data, which is usually what you want, but say so explicitly in an interview.
Bash
1# writes target/sources.json with the latest load time per source2dbt source freshness
3# sources newer than in ./prod-artifacts/sources.json, plus their children4dbt build --select "source_status:fresher+" --state ./prod-artifacts
Finance, product and the BI tool each compute "active customers" differently. What does the dbt Semantic Layer give you, and what do you define to get one shared metric?
MediumCI, State Selection and the Semantic Layer
Sample Answer
The Semantic Layer moves metric definitions into the dbt project so every tool queries the same logic. MetricFlow reads semantic models built on dbt models, with entities as join keys and dimensions to group by, plus metrics, and generates the SQL, including joins between semantic models through shared entities. Metric types are simple, ratio, cumulative, derived and conversion. MetricFlow also relies on a time spine model for time-based work such as cumulative metrics. Query it with dbt sl query --metrics active_customers --group-by metric_time__month on the dbt platform, or mf query locally. Since v1.12 the YAML spec attaches the semantic model to the model itself and puts aggregation on simple metrics, so older projects have a migration step. MetricFlow is Apache 2.0 licensed.
A full production rebuild takes two hours, and during that window dashboards see some marts at the new version and others at the old one. How do you make a deploy look atomic to consumers?
HardCI, State Selection and the Semantic Layer
Sample Answer
Use a blue-green, or write-audit-publish, deploy. Point the production job at a staging schema such as marts_next, run dbt build there so every model is built and tested, and only if the build passes, swap the staging schema with the live one in one metadata operation. On Snowflake, ALTER SCHEMA analytics.marts_next SWAP WITH analytics.marts exchanges the names atomically, so dashboards move from the old complete set to the new complete set at once. Run it from a macro with dbt run-operation. Traps: dbt compiles refs to fully qualified names, so views built in marts_next keep pointing at marts_next after the swap. Grants must exist on both schemas. Incremental models need the previous data in the staging schema first, which dbt clone or a zero-copy clone provides.
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.
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.
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.