Modern stack

dbt for Data & Analytics Engineers

Models, tests, sources and docs in dbt, and how a project is structured.

  • Handwritten-style
  • Diagrams and tables
  • Worked examples

Who this notebook is for

Analysts and engineers adopting dbt, and candidates who need to explain how a dbt project is structured and tested.

What you will be able to do

  • Choose the right materialization for a model
  • Write incremental models and Jinja macros
  • Track history with snapshots and protect quality with tests and contracts
  • Set up CI with slim builds and document lineage

What's inside

Pick a chapter and the notebook opens right there.

  1. What dbt Is & Core LifecycleT in ELT, compile vs run lifecycle, AST generation, project layout, profiles.yml, dev/staging/prod targets, environment variables, dbt Core vs Cloud vs Fusion engineStart here
  2. Models & Materializationsview, table, ephemeral, incremental, materialized_view; ref() and source() DAG lineage building; node selection syntax (tag:, +, @, intersection & selectors.yml)Start here
  3. Incremental Models in Depthis_incremental() macro, schema evolution, strategies (append, merge, delete+insert, insert_overwrite, microbatch), unique keys, late data, lookbacks & full-refresh trapsStart here
  4. Jinja & Custom MacrosControl flow, context variables, custom DDL generators, run_query(), dynamic column pivots, packages (dbt_utils, dbt_expectations, codegen) & cross-cloud adapter.dispatch()Start here
  5. Sources, Seeds & Snapshots (SCD2)source freshness, max_loaded_at, warn/error thresholds; static seeds & limits; Snapshots SCD Type 2 (timestamp vs check strategies, dbt_valid_to & hard deletes)Start here
  6. Testing & Quality AssuranceGeneric tests (unique, not_null, accepted_values, relationships), singular tests, store_failures, limit/where clauses, unit tests (dbt 1.8+ mock fixtures) & layer test strategyStart here
  7. dbt Mesh, Contracts & GovernanceModel contracts (enforced: true), column data types & constraints, model versioning & deprecation, dbt Mesh (cross-project ref, access modifiers, groups)Start here
  8. Project Structure & Dimensional ModelingStaging (stg), Intermediate (int), Marts (fct, dim); grain discipline & surrogate primary keys; Kimball star schemas vs One Big Table (OBT) in columnar cloud warehousesStart here
  9. Semantic Layer & MetricFlowSemantic models, entities, measures, metric types (simple, cumulative, derived, ratio, conversion), dimensions, time grains, BI tool exposures & join fan-out preventionStart here
  10. Documentation & Metadata Lineagedocs generate, doc blocks, markdown overviews; metadata artifacts (manifest.json, run_results.json, catalog.json); column-level lineage & automated catalog synchronizationStart here
  11. Performance, Cost & Warehouse TuningSnowflake clustering, BigQuery partition/cluster, Delta liquid; threads tuning & parallelism; query tagging with dbt query_comment & slashing warehouse bills by 50%Start here
  12. CI/CD & Slim CI DeploymentSlim CI with state:modified+ and manifest deferral (--defer -- state); GitHub Actions pipelines; ephemeral PR schemas; orchestrator integration (Airflow Cosmos, Dagster & dbt Cloud)Start here
  13. Python Models & Alternative Enginesdbt Python models (Snowpark, PySpark, BigQuery DataFrames); ML feature preparation & NLP; comparative architecture: dbt Core vs SQLMesh virtual environmentsStart here
  14. Staff Drills & Cheat Sheet1,000-model enterprise platform architecture, silent metric drift incident postmortem, 50TB broken incremental recovery runbook, Senior AE interview deep- dive & Ultimate dbt Staff Cheat SheetStart here

Practice this

Put it to work on LakeBench.

Read the guide first

Short explainers that pair with this notebook.

Common questions

Do I need to know SQL first?
Yes. dbt is SQL plus structure, so basic SELECT, JOIN and GROUP BY knowledge helps. The SQL notebook covers that.
Does it cover the semantic layer?
Yes. There is a chapter on the semantic layer and MetricFlow, and another on dbt Mesh and contracts for larger teams.
Can I read a sample before I commit?
Yes. The contents pages and the first pages of every notebook can be read online, so you can judge the style before going further.

More in Modern stack

All notebooks