Skip to main content
InterviewHubPRO
HomeTracksSection 47: dbt Analytics Engineering (50 Qs)
Section 47 of 6450 Questions (1 Per Page)

dbt (Data Build Tool) & Modern Analytics Engineering Master Interview Bank

dbt Core & dbt Cloud, DAG compilation, ref() and source(), incremental models (merge, insert_overwrite), snapshots (SCD Type 2), Jinja macros, and Slim CI.

Curriculum Roadmap & Learning Path

3 Stages
Tip: Click any stage card above to instantly filter the question bank to that topic.3 Connected Milestones
50 of 50 Qs

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

12 Questions
1
Junior#dbt#dbt Core Concepts

What is dbt and what problem does it solve in modern data engineering?

dbt (data build tool) is an open-source command-line tool that enables data analysts and data engineers to transform data in their cloud data warehouse (Snowflake, BigQuery, Databricks, Redshift, Postgres) simply by writing modular SQL SELECT statements.: The "T" in ELT: dbt does not extract or load data; it strictly handles the...

2
Junior#dbt#dbt Core Concepts

Explain the standard anatomy of a dbt project.

A dbt project is a directory of SQL, YAML, and Jinja files governed by dbtproject.yml: dbtproject.yml: The central configuration file specifying project name, version, materializations, and model configurations.

3
JuniorCode#Vue & Nuxt

What is the `ref()` function and why is it revolutionary?

In traditional SQL pipelines, queries hardcode physical table names (SELECT * FROM analyticsprod.dimcustomers). If you switch to a development schema, your queries break or accidentally overwrite production!

4
JuniorCode#dbt#dbt Core Concepts

What is the `source()` function and how does Source Freshness work?

While ref() references other dbt models, source('sourcename', 'tablename') references raw, untransformed tables loaded into the warehouse by ingestion tools (Fivetran, Airbyte, Kafka). #### Source Definition & Freshness Checks.

5
JuniorCode#dbt#dbt Core Concepts

What are Materializations in dbt?

Materializations determine how the SQL query in a model is physically created inside the warehouse: view: Creates a standard SQL View (CREATE VIEW ...) • table: Creates a physical table (CREATE TABLE .. • incremental: Appends or merges only new/modified rows since the last run.

6
Junior#dbt#dbt Core Concepts

What are Seeds in dbt and when should they NOT be used?

Seeds are static CSV files placed in the seeds/ folder and loaded into database tables using the dbt seed command.: Appropriate Use: Static lookup tables that change rarely (country code mappings, zip codes, marketing campaign metadata, employee ID mappings).

7
JuniorCode#TypeScript

What are the 4 Out-of-the-Box Generic Tests in dbt?

dbt provides 4 built-in schema tests declared in YAML: unique: Asserts that no two rows have the same value in the specified column (verifies primary key integrity) • notnull: Asserts that every row in the column contains a non-null value.

8
JuniorCode#TypeScript

What is the difference between Generic Tests and Singular Tests?

Generic Tests: Reusable validation rules defined in YAML on columns (like unique, not_null, or custom generic test macros) • Singular Tests: One-off SQL queries saved as .sql files inside the tests/ directory.

9
Junior#dbt#dbt Core Concepts

How do automated Documentation and Lineage work in dbt?

Running dbt docs generate inspects your project SQL, YAML descriptions, and metadata, generating a static web catalog: Displays table column types, descriptions, tests, and source system tags • Renders an interactive Lineage Graph (DAG) showing every upstream raw source and downstream mart connected to each model.

10
Junior#CLI

Explain core dbt CLI execution commands and Node Selection syntax.

dbt run: Executes and builds models in the warehouse • dbt test: Runs all generic and singular tests • dbt build: The modern unified command that runs models, tests, snapshots, and seeds in DAG dependency order (stops downstream models if an.

11
JuniorCode#dbt#dbt Core Concepts

How does Jinja Templating work in dbt?

dbt combines SQL with the Jinja2 templating language: {{ .. • {% .

12
Senior#System Design

What is the recommended Medallion Architecture structure in dbt?

Organizing models into three distinct layers ensures modular, maintainable pipelines: Staging Layer (models/staging/) (Bronze): 1-to-1 view/table on top of raw sources • Intermediate Layer (models/intermediate/) (Silver): Joins multiple staging models, aggregates intermediate metrics, and applies complex business.

Part 2: Advanced Modeling, Incremental Builds & Macros (Mid-Level)

12 Questions
13
JuniorCode#dbt#Advanced Modeling

How do Incremental Models work in dbt and what are the strategies?

Rebuilding a 2-billion-row fact table from scratch every hour wastes compute and time. An Incremental Model builds as a full table on the first run, but on subsequent runs processes only new or updated rows using the is_incremental() macro.

14
JuniorCode#dbt#Advanced Modeling

What are dbt Snapshots and how do they implement SCD Type 2?

Source databases often overwrite records (SCD Type 1). dbt Snapshots record historical mutations over time to maintain an immutable audit trail (SCD Type 2).: timestamp Strategy: Compares an updated_at column to detect mutations • check Strategy: Calculates a checksum over specified columns to detect edits when no timestamp column exists.

15
JuniorCode#dbt#Advanced Modeling

How do you create Custom Jinja Macros?

Macros are reusable SQL functions stored in macros/.

16
JuniorCode#dbt#Advanced Modeling

What are dbt Packages and how do you install them?

Packages are external open-source libraries containing pre-built macros, tests, and models. Declared in packages.yml and installed via dbt deps: dbt-labs/dbtutils: Essential macros like surrogatekey(), generateseries(), pivot() • calogica/dbtexpectations: Great Expectations test suite inside dbt.

17
JuniorCode#dbt#Advanced Modeling

What are Model Contracts and why are they vital for Data Contracts?

Historically, if upstream SQL changed a column from INT to STRING, downstream BI dashboards crashed silently.

18
Junior#dbt#Advanced Modeling

What is the dbt Semantic Layer and MetricFlow?

In organizations, marketing might calculate "Active Users" as logged in within 30 days, while finance calculates it as 7 days.

19
MidCode#dbt#Advanced Modeling

How do Python Models work in dbt?

Starting in dbt 1.3+, models can be written in Python (.py) instead of SQL on platforms with native Python compute (Snowflake Snowpark, Databricks, BigQuery, PySpark).: Ideal for data science, training ML models, text sentiment analysis, or complex statistical operations that are painful in SQL.

20
MidCode#dbt#Advanced Modeling

How do dbt Profiles and Target Environments work?

Credentials are kept separate from code. Your Git repository stores project logic, while database passwords reside in ~/.dbt/profiles.yml: Developers use target: dev (writes to personal scratch schema dbt_jdoe) • CI/CD runners use target: prod (writes to production schemas).

21
Junior#Hooks

What are Pre-Hooks and Post-Hooks in dbt?

SQL statements executed before or after a model or project run: pre-hook: Useful for session settings or temporary table prep (ALTER SESSION SET ...) • post-hook: Useful for granting permissions to BI reporting roles (GRANT SELECT ON {{ this }} TO ROLE bi_reporting;).

22
Junior#dbt#Advanced Modeling

What are Exposures in dbt?

Exposures map downstream consumers of your data (e.g. Looker Dashboards, Executive Metabase boards, critical ML pipelines) in your project YAML. They show up in the dbt documentation lineage graph. When a data engineer modifies stg_orders, they can instantly see which executive dashboards will be impacted!

23
Mid#dbt#Advanced Modeling

Compare dbt Core vs dbt Cloud.

Dimension dbt Core dbt Cloud.

24
JuniorCode#TypeScript

How do you create Custom Generic Test Macros?

Create a macro in macros/ with the prefix test_. The test must return failing rows.

Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)

26 Questions
25
Most AskedSenior#Forms#Performance

What is Slim CI in dbt and how does it reduce PR build times?

In a 1,000-model project, running dbt build on every developer pull request takes hours and racks up thousands of warehouse credits.

26
Most AskedSeniorCode#Forms#Performance

How do you handle Late-Arriving Data in Incremental Models?

If an order placed on Monday is held up by payment processing and arrives on Thursday, a naive incremental filter (WHERE updatedat > (SELECT MAX(updatedat) FROM {{ this }})) will completely miss the Monday record! Subtract a safety window (e.g., 3 days) from the incremental filter to capture late-arriving dimensions.

27
Most AskedSeniorCode#Forms#Performance

How does Native Unit Testing work in dbt 1.8+?

Before dbt 1.8, tests ran only against live database tables. Unit Tests mock static input rows directly in YAML and assert expected output rows without touching production data.

28
Most AskedSenior#Forms#Performance

How do you tune performance for massive dbt DAGs?

Parallel Threads (--threads 16): Increase thread concurrency so independent branches of the DAG execute concurrently • Optimize Materializations: Demote rarely queried tables to ephemeral or view to eliminate warehouse write I/O.

29
Most AskedSenior#Forms#Performance

How do you implement Zero-Downtime Blue/Green Deployments with dbt?

In production CI/CD, build all models into a temporary "Green" schema (prodgreen) • Run all data quality tests on prodgreen • If all tests pass, execute an atomic metadata schema swap (ALTER SCHEMA prod SWAP WITH prod_green;) • Downstream BI queries never experience intermediate drop or table rebuild errors!.

30
Most AskedSenior#Forms#Performance

How do you orchestrate dbt with Apache Airflow using Astronomer Cosmos?

Running BashOperator(bash_command='dbt run') treats dbt as a black box—if one model fails, the entire Airflow task fails without showing which model broke. Cosmos parses your dbt manifest.json and dynamically translates every individual dbt model into a native Airflow Task: Full visual task graph in Airflow UI.

31
Most AskedSenior#Forms#Performance

What is dbt Mesh and Multi-Project Architecture?

When enterprise data teams grow to 100+ analysts, a single monolithic dbt repository becomes chaotic with PR merge conflicts. dbt Mesh splits the monolithic repo into domain-driven repositories (e.g., corefinance, coremarketing, core_product): Models specify access: public or private.

32
Most AskedSenior#Forms#Performance

How do you track and audit query costs generated by dbt?

Use packages like dbt-artifacts: On on-run-end, dbt automatically writes execution metadata (compilation time, execution duration, rows affected, query ID) into a dedicated • Join this table with Snowflake's QUERY_HISTORY to accurately attribute cloud compute costs to specific data models and teams.

33
Most AskedSenior#Forms#Performance

How do you refactor legacy stored procedures into modern dbt models?

Break down 2,000-line monolithic stored procedures into CTEs • Separate business logic from ingestion: extract raw loading into staging models • Replace temporary tables (#temp_table) with modular intermediate models • Replace procedural loops (WHILE / CURSOR) with set-based SQL joins and Jinja macros.

34
Most AskedSenior#Forms#Performance

How do you secure CI/CD runners executing dbt in production?

Never hardcode warehouse passwords in Git • Use Cloud Service Accounts with OpenID Connect (OIDC) or RSA Key-Pair authentication • Restrict CI/CD database roles with the principle of least privilege (only write access to target schemas, zero admin or user-management privileges).

35
Most AskedSenior#Forms#Performance

What is the future of Analytics Engineering and Streaming dbt?

Streaming Transformations: Integrating dbt with streaming engines like Materialize or Apache Flink for real-time sub-second materialized views • AI & Agentic Modeling: Autonomous agents reading business requirements and generating validated dbt models with unit tests and contracts.

36
Most AskedSeniorCode#Forms#Performance

Model Contracts and Model Governance (`contract: { enforced: true }`): Enforcing schemas and non-breaking changes.

Without contracts, upstream engineers can change a column from integer to string or drop a column, silently breaking downstream analytics models: Model Contracts: Guarantees that the model's compiled SQL strictly conforms to the exact column names and data types defined in YAML.

37
Most AskedSeniorCode#Forms#Performance

Model Versions (`latest_version` / `v1`, `v2`): Managing deprecation cycles and non-breaking migrations.

When making breaking changes to a core public dimension table used by 50 downstream dashboards.

38
Most AskedSeniorCode#Forms#Performance

dbt Semantic Layer and MetricFlow: Defining metrics once for consistent enterprise BI queries.

Different departments often calculate "Monthly Active Users" or "Gross Revenue" differently in their own SQL queries, causing conflicting board meeting metrics: Semantic Layer: Define the single source of truth for business metrics in YAML.

39
Most AskedSeniorCode#Forms#Performance

dbt Python Models: When and how to run Python scripts in Snowflake, Databricks, and BigQuery.

SQL is ideal for set-based data transformations; Python is ideal for complex statistical analysis, NLP parsing, and machine learning scoring.

40
Most AskedSeniorCode#Forms#Performance

dbt Unit Testing (`unit_tests:`): Testing SQL logic with mocked inputs and expected outputs.

Traditional dbt tests (not_null, unique) test the quality of live data. Unit Tests test the correctness of your SQL logic using static mocked data without querying real warehouse tables.

41
Most AskedSeniorCode#Forms#Performance

Advanced Node Selection Syntax: Graph operators, state comparisons, and tagging strategies.

Mastering dbt CLI selection syntax saves hours of developer time.

42
Most AskedSeniorCode#Forms#Performance

Slim CI Workflows: Running and testing only modified models using production `manifest.json`.

Running 1,000 dbt models on every pull request commit costs $500 and takes 45 minutes: Slim CI Architecture • Download the production manifest.json artifact generated during the last successful nightly run • Execute.

43
Most AskedSeniorCode#Forms#Performance

Exposures and Data Lineage: Connecting dashboards, ML models, and reverse-ETL tools.

Exposures document downstream consumers of your data models directly inside dbt documentation.

44
Most AskedSeniorCode#Forms#Performance

Custom Materializations: Writing custom Jinja materialization blocks.

When standard materializations (view, table, incremental) don't fit (e.g. exporting data directly to cloud object storage or updating a specialized vector index): Define custom materialization logic in macros/materializations/.

45
Most AskedSenior#Forms#Performance

Ephemeral vs View vs Table vs Incremental: Memory, performance, and storage tradeoffs.

Materialization Stored in Warehouse? Query Performance Build Duration Best Use Case.

46
Most AskedSenior#Forms#Performance

dbt Seeds vs External Dictionaries: Limitations and best practices.

dbt seed loads small, static CSV files stored in seeds/ directly into data warehouse tables: Ideal Use Cases: Country code mappings (ISO 3166), employee department lookups, currency codes • Critical Limitations • Seeds are committed directly into Git.

47
Most AskedSeniorCode#Hooks#Forms

Hooks in dbt: `on-run-start`, `on-run-end`, `pre-hook`, and `post-hook`.

Executing arbitrary SQL before and after model or run execution.

48
Most AskedSeniorCode#Forms#Performance

Working with Complex JSON Payloads in dbt: Macro patterns for cross-warehouse unnesting.

Unnesting JSON arrays differs drastically across warehouses (Snowflake uses FLATTEN(), BigQuery uses CROSS JOIN UNNEST(), Postgres uses jsonarrayelements()).: Cross-Database Macros: Write adapter-aware macros using adapter.dispatch so your model code remains clean and portable.

49
Most AskedSenior#Forms#Performance

Performance Profiling in dbt: Diagnosing long compile times, circular references, and slow models.

Optimizing slow enterprise dbt projects: Compilation Delays: Excessively nested Jinja macros and thousands of model references slow down dbt compile • Circular References: Occurs when Model A refs Model B and Model B refs Model A.

50
Most AskedSenior#Forms#Performance

Building a Production Enterprise dbt Repository: Medallion Architecture best practices.

Organizing thousands of models into a maintainable, structured directory layout: Staging / Bronze (models/staging/) • 1-to-1 mapping with source tables (stgstripepayments.sql) • Clean column names, cast data types, handle timezone normalization • Intermediate / Silver (models/intermediate/).