0
0
dbtdata~10 mins

Materializations strategy in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Materializations strategy
Start: Define model
Choose materialization type
Table
Create physical table
View
Create virtual view
Incremental
Append or update data
Ephemeral
Inline CTE in queries
Run dbt model
Materialization applied
Data ready for use
This flow shows how dbt chooses a materialization strategy for a model and applies it to create tables, views, or inline queries.
Execution Sample
dbt
model.sql:
-- materialized as table
select * from source_table

-- materialized as view
{{ config(materialized='view') }}
select * from source_table

-- materialized as incremental
{{ config(materialized='incremental') }}
select * from source_table

-- materialized as ephemeral
{{ config(materialized='ephemeral') }}
select * from source_table
This code shows four dbt models with different materialization strategies: table, view, incremental, and ephemeral.
Execution Table
StepModel TypeActionResult
1tabledbt runs model.sqlCreates physical table with full data
2viewdbt runs model.sql with view configCreates virtual view referencing source_table
3incrementaldbt runs model.sql with incremental configAppends or updates only new/changed data in table
4ephemeraldbt runs model.sql with ephemeral configInlines SQL as CTE in dependent models, no table/view created
5alldbt finishes runModels materialized as per config, data ready for queries
💡 All models processed with their materialization strategy; dbt run completes successfully
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
model_typeundefinedtableviewincrementalephemeralall processed
physical_objectnonetable createdview createdtable updated incrementallyno object createdall materialized
data_statesource datafull data copiedvirtual view points to sourcepartial data updateddata inlined in queriesready for use
Key Moments - 3 Insights
Why does the ephemeral materialization not create a table or view?
Because ephemeral models are inlined as CTEs inside dependent models, no physical object is created. See execution_table row 4.
How does incremental materialization differ from table materialization?
Incremental only adds or updates new data instead of recreating the whole table, making it faster. See execution_table rows 1 and 3.
What happens if you don't specify a materialization in dbt?
By default, dbt materializes models as tables, creating a physical table with full data. See execution_table row 1.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what does dbt do at Step 2 for a view model?
ACreates a physical table with data
BAppends new data to an existing table
CCreates a virtual view referencing source_table
DInlines SQL as a CTE in dependent models
💡 Hint
Check execution_table row 2 under 'Result' column
At which step does dbt update only new or changed data instead of recreating the whole table?
AStep 3
BStep 2
CStep 1
DStep 4
💡 Hint
Look at execution_table row 3 describing incremental materialization
If you want no physical table or view created, which materialization should you choose?
Aview
Bephemeral
Cincremental
Dtable
💡 Hint
Refer to execution_table row 4 about ephemeral materialization
Concept Snapshot
dbt Materializations:
- table: creates physical table with full data
- view: creates virtual view
- incremental: updates/appends data
- ephemeral: inlines SQL, no table/view
Choose based on performance and use case
Run dbt to apply chosen materialization
Full Transcript
This visual execution shows how dbt applies different materialization strategies to models. First, you define your model SQL and choose a materialization type: table, view, incremental, or ephemeral. When dbt runs, it creates a physical table for 'table' models, a virtual view for 'view' models, updates only new or changed data for 'incremental' models, and inlines SQL as CTEs for 'ephemeral' models without creating physical objects. Variables like model_type and physical_object change step-by-step as dbt processes each model. Key points include understanding that ephemeral models do not create tables or views, incremental models update data efficiently, and the default is table materialization if none is specified. The quizzes test your understanding of these steps and outcomes. This helps you choose the right materialization for your data workflow.