What dbt is (and is not)
dbt is the transformation layer of a modern data stack: you write SELECT statements, and dbt turns them into tables and views in your warehouse, in the right order, with tests and documentation.
Pipelines in production · dbt · Bronze · Project basics, lesson 1 of 2
On this page
In plain words first
Think of a cookbook for your warehouse. Each recipe (a model) is a SELECT that says how to make one table from others. dbt reads all the recipes, works out which must be cooked first, cooks them in the right order inside the warehouse, and checks the results taste right (tests).
The T in ELT
Older pipelines transformed data before loading it (ETL). Cloud warehouses made storage and compute cheap enough to load raw data first and transform it inside the warehouse with SQL (ELT). dbt owns that last step.
-
Extract + load
Fivetran, Airbyte, custom jobs
-
Raw tables
In the warehouse
-
Transform
dbt models
-
Consume
BI, ML, reverse ETL
dbt does not move data between systems, schedule itself or store data. It connects to one warehouse (Snowflake, BigQuery, Databricks, Redshift, Postgres, DuckDB and others through adapters) and runs SQL there. The warehouse does all the computing.
A model is a SELECT
A model is one .sql file in models/ that contains one SELECT. The file name becomes the name of the table or view dbt builds. You never write CREATE TABLE or INSERT: dbt wraps your query in the right DDL for the materializationmaterialization: How dbt stores a model: as a view, a table, an incremental table that only adds new rows, or ephemeral (inlined, not stored). Learn more → you chose.
select i.invoice_id, i.account_id, i.issued_at, i.total, coalesce(sum(c.amount), 0) as amount_charged from {{ ref('stg_invoices') }} as i left join {{ ref('stg_charges') }} as c on c.invoice_id = i.invoice_id group by 1, 2, 3, 4
The examples in this track use one imaginary product: a music subscription app with accounts, invoices, card charges and song plays. The {{ ref(...) }} calls are JinjaJinja: The template language dbt runs before sending SQL: {{ }} inserts a value, {% %} runs logic such as loops and ifs. Learn more →, a template language. They are how dbt learns that fct_invoices depends on two other models, so it can build them first.
Compile, then run
- 1Parse: dbt reads every model, YAML file and macromacro: A reusable piece of Jinja, like a function that returns SQL. You call it with {{ my_macro(...) }}. Learn more → and builds the dependency graph (the DAGDAG: The graph of models that ref() calls create. dbt uses it to build models in dependency order. Learn more →).
- 2Compile: Jinja is rendered into plain SQL.
{{ ref('stg_invoices') }}becomes a fully qualified name such asanalytics.dbt_alice.stg_invoices. The result is written totarget/compiled/. - 3Run: dbt wraps the compiled query in DDL (for a table:
create or replace table ... as (select ...)), sends it to the warehouse, and walks the DAG so every model runs after its parents, several at a time.
dbt compile --select fct_invoices # render Jinja only, nothing runs dbt run --select fct_invoices # build the model dbt test --select fct_invoices # run its data tests dbt build # run, test, snapshot and seed everything in DAG order
target/compiled/ (or target/run/ for the wrapped DDL). The error is about that SQL, not your Jinja.What dbt adds on top of SQL files
Dependencies
ref() and source() build the DAG, so order and parallelism are automatic.Environments
Tests
unique and not_null run as queries after each build.Documentation
dbt docs generate builds a site with every model, column description and the lineage graph.Reuse
Incremental builds
Core, the platform and Fusion
| Name | What it is |
|---|---|
| dbt Core | The open-source command-line tool (Python). You run it yourself, usually from an orchestrator such as Airflow, Dagster or a CI job. |
| The dbt platform | dbt Labs' hosted product (formerly dbt Cloud): an IDE, job scheduler, CI on pull requests, hosted docs and the semantic layer. |
| dbt Fusion | A newer engine written in Rust that parses projects much faster and understands the SQL it compiles. Same project files. |
Everything in this track works the same in all three: projects are plain files, and the concepts (models, refs, tests, materializations) do not change.
Common mistakes
- Expecting dbt to load data — Pointing a model at a file in S3 or an API does not work: a model can only SELECT from tables already in the warehouse. Load them first with Fivetran, Airbyte or a custom job.
- Writing CREATE TABLE in a model — dbt wraps the file in its own DDL, so
CREATE TABLE fct_invoices AS SELECT ...becomescreate or replace table ... as (CREATE TABLE ...)and the warehouse rejects it. Keep only the SELECT and choose a materialization. - Hard-coding table names —
FROM analytics.stg_invoicesreads production even in your dev schema, and dbt does not know about the dependency, so it may build this model first. Use{{ ref('stg_invoices') }}.
Key takeaways
- The warehouse does all the computing: a slow model is fixed in its SQL and the warehouse, not in dbt.
- When a model fails, read
target/compiled/: it holds the plain SQL dbt sent, with everyrefresolved. - The same project runs in dbt Core, the dbt platform and Fusion; models, refs, tests and materializations do not change.
- Interview angle: a SELECT per model, a DAG from
ref(), and software practices for SQL: version control, environments, tests and docs.
Interview prep
THE QUESTION
"What is dbt, and what problem does it solve?"
ref() and source(), and builds tables and views in the warehouse in DAG order. It brings software practices to SQL: version control, environments, tests, documentation, code reuse through macros, and incremental builds. The warehouse does the compute; dbt does not extract, load or store data.Avoid: "dbt is an ETL tool". dbt does not extract or load anything: it compiles SELECTs and the warehouse runs them.
Follow-ups · answer out loud, then open
Follow-up"What happens, step by step, when you type dbt run?"
threads models at a time. It writes manifest.json and run_results.json to target/.Scenario"A team has 300 SQL scripts run by cron in a fixed order. What would moving to dbt give them?"
Trap"Does dbt make queries faster?"
Check yourself
3 questionsWhat does a dbt model file contain?
Show the answer
A single SELECT statement, optionally with Jinja. dbt wraps the SELECT in the DDL that the materialization needs.
Where does the computation in a dbt run happen?
Show the answer
In the warehouse dbt connects to. dbt sends SQL; the warehouse executes it.
How does dbt know that fct_invoices must run after stg_invoices?
Show the answer
fct_invoices uses {{ ref('stg_invoices') }}. ref() records the dependency in the DAG.
Practise this
Problems that use this, graded on hidden tests
Keep going
Up next · Project basics · lesson 2 of 2 · 5 min readA dbt project, file by file
dbt_project.yml, profiles and targets, and the staging, intermediate and marts layout teams use.
Related lessons
Primary sources: What is dbt?