What is dbt? It is an open source command line tool and cloud service, short for data build tool, that lets analysts and engineers transform data inside a warehouse using SQL and software engineering practices. dbt does the T in ELT: once raw data has been loaded into a platform such as Snowflake, BigQuery, Databricks or Redshift, dbt runs SQL models in dependency order, builds tables and views, tests the results, generates documentation and records lineage. It brings version control, code review, testing and continuous integration to analytics work that was once a tangle of ad hoc queries. This guide explains how dbt works, its core concepts, how it fits in a modern data stack, how to adopt it and the pitfalls to avoid.
Short answer: dbt compiles SQL select statements into tables and views in your warehouse, manages dependencies between them, runs tests and builds documentation and lineage. It makes data transformation modular, testable and version controlled.
What is dbt?
dbt was created by Fishtown Analytics, now dbt Labs, and popularised the role of the analytics engineer. The dbt software article on Wikipedia gives background. It is a leading tool for the transformation step in ELT, described in data integration and ETL, and it runs on top of a data warehouse, for example Snowflake. It is closely linked with data modeling and data lineage.
How dbt works

- Load raw data. A tool such as Fivetran or Airbyte loads data into the warehouse. dbt does not extract or load.
- Write models. Each model is a SQL select statement in its own file that defines a table or view.
- Reference other models. Models use ref() to depend on each other, which lets dbt build a dependency graph.
- Run the project. dbt compiles SQL, then executes models in the correct order inside the warehouse.
- Test the output. Built in and custom tests check uniqueness, not null, accepted values and relationships.
- Document and visualise. dbt generates documentation and a lineage graph from the code.
- Deploy through CI/CD. Changes go through pull requests, automated tests and scheduled production runs.
Core dbt concepts
| Concept | What it is | Why it matters |
|---|---|---|
| Model | A SQL select statement saved as a file | The basic unit of transformation |
| Source | Declaration of raw tables loaded from other systems | Tracks freshness and lineage from the start |
| Materialisation | How a model is built: view, table, incremental or ephemeral | Controls cost and speed |
| Test | An assertion about the data | Catches problems early |
| Seed | A small CSV loaded as a table | Reference lists and mappings |
| Snapshot | Tracks changes to a table over time | History of slowly changing data |
| Macro | Reusable code written in Jinja | Avoid duplication and encode standards |
| Package | Shared dbt code from the community | Reuse common logic |
| Semantic layer and metrics | Central definitions of business metrics | Consistent numbers across tools |
Typical dbt project structure
| Layer | Purpose | Example |
|---|---|---|
| Staging | Light cleaning and renaming of each source table | stg_orders, stg_customers |
| Intermediate | Reusable joins and business logic | int_orders_enriched |
| Marts | Final, business facing tables for analytics | fct_orders, dim_customers |
| Metrics | Agreed calculations of key measures | revenue, active customers |
| Tests and documentation | Quality and description for each layer | Unique key tests, column descriptions |
Benefits of dbt
- Analytics logic lives in version controlled code that can be reviewed and rolled back.
- Automated tests catch broken joins, duplicate keys and bad values before users do.
- Dependency awareness means dbt runs only what is needed and in the right order.
- Documentation and lineage are generated from the code and stay current.
- Analysts can contribute using SQL, which they already know.
- It works across major warehouses, reducing lock in.
dbt compared with other approaches
| Approach | Strengths | Limits |
|---|---|---|
| dbt | SQL first, testing, lineage, community and packages | Focused on transformation inside the warehouse |
| Stored procedures and scheduled queries | Native and simple at first | Hard to test, document and manage dependencies |
| Traditional ETL tools | Visual design, broad connectors | Heavier, less aligned with software practices |
| Spark and code based pipelines | Flexible, powerful for complex processing | More engineering effort. See what is Apache Spark |
| Orchestrators such as Airflow | Schedule and coordinate any task. See what is Apache Airflow | Not a transformation framework itself |
How to adopt dbt
- Pick a focused starting area. Choose one domain, such as finance or marketing, with clear value and a cooperative team.
- Set up the project and environments. Create a repository, development and production schemas and a service account with limited rights.
- Declare sources and build staging models. Capture raw tables with freshness checks and standardise names and types.
- Build marts with tests. Create business facing models and add tests for keys and relationships.
- Add CI and code review. Run tests on every pull request, and use slim builds to check only changed models.
- Schedule and monitor. Run on a schedule or via an orchestrator and alert on failures and test breaches.
- Establish standards. Agree naming, folder structure, style and documentation expectations, then train the wider team.
Common dbt mistakes
- Putting all logic in a few giant models that nobody understands.
- Skipping tests, so errors appear in dashboards first.
- Materialising everything as tables, driving up cost.
- Not using incremental models for very large tables.
- Allowing inconsistent naming and style across teams.
- Treating dbt as a replacement for data modelling and governance rather than a tool to implement them.
Our data analytics service builds dbt projects with testing and CI, and our data warehousing service designs the warehouse models they produce.
A worked example: ending spreadsheet logic
A marketplace company calculates revenue in several dashboards, each with its own SQL, and finance disputes the numbers every month. The data team introduces dbt. Raw tables from the payment processor, orders database and refunds system are declared as sources with freshness checks. Staging models standardise columns, and a revenue model joins orders, payments and refunds using rules agreed with finance, then publishes a single orders fact table.
Tests assert that every order has one payment record and that refunds never exceed payments, and CI blocks changes that break them. Documentation and lineage show finance exactly how revenue is derived. Dashboards are rebuilt on the single model, and disagreements about the number end. New metrics take days rather than weeks to add, because analysts extend a tested model instead of writing a new query from scratch.
Performance and cost in dbt projects
Because dbt runs inside the warehouse, cost follows the queries it generates. Use views for lightweight transformations, tables for models read often and incremental models for large event tables, so that each run processes only new data. Limit full refreshes to when logic changes, partition and cluster large tables, and watch the slowest models in run logs. Review warehouse spend by model owner, remove unused models and schedule heavy jobs sensibly. These habits keep a growing project fast and economical.
Governance with dbt
dbt can encode many governance practices. Model contracts enforce column names and types, access controls limit who can query sensitive models and ownership metadata shows who maintains each one. Tags can mark personal data and drive masking policies, and exposures describe the dashboards and applications that depend on models. Combined with a catalog, these features give both engineers and stewards a shared view of what exists, who owns it and what depends on it.
Key takeaways
- dbt transforms data inside the warehouse using SQL models, dependencies, tests and documentation.
- It brings software engineering practices to analytics: version control, review and CI.
- A layered structure of staging, intermediate and mart models keeps projects clear.
- Control cost with the right materialisations and incremental models.
- Adopt it one domain at a time and agree standards early.
Quick glossary
| Term | Meaning |
|---|---|
| Model | A SQL file that defines a table or view |
| ref() | A function that declares a dependency on another model |
| Materialisation | How dbt builds a model in the warehouse |
| Incremental model | A model that processes only new or changed data |
| Analytics engineer | A role that builds reliable, tested data models |
Read next: BigQuery vs Snowflake: Which Cloud Data Platform? · BigQuery Streaming Inserts: Real-Time Ingestion Guide · BigQuery Access Control: IAM, Policy Tags and Row Security
Frequently asked questions
What is dbt in simple terms?
It is a tool that lets you write SQL to transform data in your warehouse, with tests, documentation and version control, so analytics logic is reliable and reusable.
What does dbt stand for?
dbt stands for data build tool.
Does dbt extract and load data?
No. dbt handles the transformation step. Other tools load raw data into the warehouse, and dbt then transforms it.
Is dbt free?
dbt Core is open source and free. dbt Cloud is a paid service with a hosted development environment, scheduling and additional features.
Which warehouses does dbt support?
Major platforms including Snowflake, BigQuery, Redshift, Databricks and Postgres, through adapters.
What is the difference between dbt and Airflow?
dbt transforms data using SQL models. Airflow orchestrates tasks of any kind. They are often used together, with Airflow triggering dbt runs.
What are dbt tests?
They are assertions about data, such as unique, not null, accepted values and relationships, that run after models are built to catch quality problems.
Who uses dbt?
Analytics engineers, data analysts and data engineers use it to build and maintain trusted data models across teams.
