dbt: Managing Data Transformations as Code
dbt treats your data transformations as a software project, letting you build, test, and version control your SQL. It's the 'T' in the modern ELT paradigm. Use it to create reliable data models in a warehouse. The footgun: dbt only transforms data.
The mental model
dbt lets you treat your data transformation logic as a software engineering project. Instead of writing isolated, hard-to-maintain SQL scripts, you build a 'dbt project' containing modular SQL models. dbt compiles these models and runs them in the correct order inside your data warehouse, applying principles like version control, testing, and documentation to your analytics code. It focuses exclusively on the 'T' (Transform) in the ELT (Extract, Load, Transform) process.
How it works
You write data models as SELECT statements in .sql files. You define relationships and dependencies between models using a ref() function. When you run dbt, it builds a Directed Acyclic Graph (DAG) of all your models. It then materializes these models as tables or views in your data warehouse in the correct order of dependency. Features like dbt State and Orchestrator intelligently determine which models need to be rebuilt based on code or data changes, saving compute time.
When to use it
Use dbt when you need to build and maintain a suite of analytics-ready data tables in a cloud data warehouse. It's ideal for teams that want to bring discipline, collaboration, and reliability to their SQL-based data modeling. It helps create a 'single source of truth' for business metrics by building layered, dependent models, for instance, raw staging tables, then intermediate transformations, and finally business-facing marts.
When not to use it
dbt is not the right tool for data extraction or loading; it assumes data is already present in your warehouse. It's also not a streaming transformation tool, as it operates in batches. For teams with very simple, infrequent transformations, the overhead of a dbt project might be unnecessary compared to a few scheduled SQL scripts.
One canonical example
An e-commerce company has raw orders and customers tables loaded into Snowflake. An analytics engineer creates a dbt project. One model, stg_orders.sql, cleans the raw orders data. Another, stg_customers.sql, cleans customer data. A final model, fct_customer_orders.sql, joins the two staging models using ref('stg_orders') and ref('stg_customers'). Running dbt run automatically builds the staging tables first, then the final joined table, ensuring the pipeline executes correctly.
Interview question
According to the card, which task is outside the primary scope of dbt's functionality?
- a.Managing version control for SQL transformation logic
- b.Creating layered, dependent data models for analytics
- c.Building a Directed Acyclic Graph (DAG) for model execution
- d.Loading raw data from external sources into a data warehouseCorrect
Why? this is the answer
The card explicitly states that "dbt is not the right tool for data extraction or loading; it assumes data is already present in your warehouse." This clarifies its focus solely on the 'T' (Transform) in the ELT process, making data loading an out-of-scope task. The other options describe core functionalities of dbt.
Just read this? Test yourself on what you have been reading.
Read the original → docs.getdbt.com
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on analytics — each one lists the topics its interview covers.
See open roles