# dbt

> A tool for writing data transformations as SQL files, with tests and docs, like software.

- Level: Advanced
- Topics: Data
- URL: https://tidbit.legios.com.ar/dbt/
- In Spanish: [dbt](https://tidbit.legios.com.ar/es/dbt/)

**dbt** (originally "data build tool") is an open source tool for the transform step of a data pipeline, the T in ELT. The data has already been loaded into a data warehouse such as Snowflake, BigQuery, Redshift or Databricks; dbt helps you turn those raw tables into clean, trusted ones. Each transformation is a **model**: a plain `.sql` file with a `SELECT` statement, saved in a git repository.

Models can refer to each other with `{{ ref('orders') }}`, so dbt knows the order in which to build them and draws the whole chain as a graph. Running `dbt run` sends each model's SQL to the warehouse, which does the heavy work; dbt itself moves no data. `dbt test` checks rules like "this column is never empty" or "every order has a customer", and `dbt docs` generates a website describing every table and column, with lineage.

Its impact was cultural as much as technical: it brought software habits like version control, code review, testing and reusable pieces to analysts who already knew SQL. That gave rise to the role of **analytics engineer**. dbt Labs, the company behind it, also sells a hosted platform, but the core tool is open source and runs from the command line.

## An analogy

A recipe book for a restaurant kitchen where each recipe says which other preparations it needs. The chef (the warehouse) does the cooking; dbt reads the book, works out the order, and checks every plate before it goes out.

## Keep in mind

- Each model is a SELECT in a .sql file; dbt builds them inside the warehouse.
- ref() links models into a dependency graph with automatic build order.
- Built-in tests and generated documentation with lineage.
- Brought git, code review and testing to SQL analytics work.

## Go deeper

- [What is dbt? (official docs)](https://docs.getdbt.com/docs/introduction)
- [dbt Core on GitHub](https://github.com/dbt-labs/dbt-core)
- [About dbt models (official docs)](https://docs.getdbt.com/docs/build/models)

## Related terms

- [Open source](https://tidbit.legios.com.ar/open-source/): Software whose code anyone can read, use, change and share.
- [ETL](https://tidbit.legios.com.ar/etl/): Copy data out of its sources, clean it up, load it where it can be analyzed.
- [Data warehouse](https://tidbit.legios.com.ar/data-warehouse/): A database built for analysis: years of history, from many sources, in one place.
- [Amazon Redshift](https://tidbit.legios.com.ar/amazon-redshift/): AWS's data warehouse: SQL over huge tables, built for analysis rather than apps.
- [Git](https://tidbit.legios.com.ar/git/): A time machine for code: every change saved, by whom and why.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [Code review](https://tidbit.legios.com.ar/code-review/): Having another person read a code change before it becomes part of the product.
- [Command line](https://tidbit.legios.com.ar/command-line/): Controlling a computer by typing text commands instead of clicking icons.
