⚙️dbt Model
Also known as Model (dbt), dbt SQL Model
One SQL file in dbt. It builds one table or view.
Think of it like
It is like one card in a recipe box. It makes one dish, and it can use dishes made by other cards.
Example
One model file adds up orders by day. dbt turns it into a table in the warehouse with the same name.
Why it matters
Definition
Example code
sql
-- models/daily_sales.sql
SELECT order_date, SUM(total) AS sales
FROM {{ ref('stg_orders') }}
GROUP BY order_dateCommon mistake
Key takeaways
- 1One file, one table. The name is the file name.
- 2Only a SELECT. dbt writes the rest.
- 3ref() and source(). How models find their inputs.