0
0
dbtdata~10 mins

Staging, intermediate, and marts pattern in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Staging, intermediate, and marts pattern
Raw Data Sources
Staging Models
Intermediate Models
Data Marts
Business Users & Reports
Data flows from raw sources to staging, then to intermediate models, and finally to data marts for business use.
Execution Sample
dbt
select * from raw.customers;
-- staging cleans and standardizes

select customer_id, upper(name) as name from staging.customers;
-- intermediate enriches

select customer_id, name from intermediate.customers;
-- marts for reporting
This code shows data moving through staging, intermediate, and marts layers with transformations at each step.
Execution Table
StepLayerActionInput DataOutput Data
1RawLoad raw customer dataRaw CSV with inconsistent namesRaw table with all columns
2StagingClean and standardize namesRaw tableNames uppercased, trimmed
3IntermediateAdd business logicStaging tableFiltered customers, enriched columns
4MartsPrepare for reportingIntermediate tableAggregated customer metrics
5EndData ready for business useData martsReports and dashboards
💡 Data is fully transformed and ready for business consumption in marts.
Variable Tracker
VariableRawStagingIntermediateMarts
customer_namemixed case, spacesUPPERCASE, trimmedUPPERCASE, filteredUPPERCASE, aggregated
Key Moments - 3 Insights
Why do we need a staging layer instead of transforming raw data directly to marts?
Staging cleans and standardizes raw data first, making later transformations simpler and more reliable, as shown in execution_table step 2.
What is the role of intermediate models between staging and marts?
Intermediate models add business logic and enrich data, preparing it for final aggregation in marts, as seen in execution_table step 3.
Can marts use raw data directly?
No, marts rely on cleaned and enriched data from intermediate models to ensure accuracy and performance, shown by the flow in concept_flow.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what transformation happens at the staging layer?
AAdd business logic and filters
BClean and standardize names
CAggregate customer metrics
DLoad raw CSV data
💡 Hint
Check execution_table row 2 under 'Action' for staging layer.
At which step does the data become ready for business use?
AStep 5
BStep 3
CStep 2
DStep 4
💡 Hint
Look at execution_table row 5 for when data is ready for business.
If we skip the intermediate layer, what is likely to happen?
AData marts will aggregate correctly
BRaw data will be cleaned properly
CBusiness logic and enrichment will be missing
DStaging will add business logic
💡 Hint
Refer to key_moments about the role of intermediate models.
Concept Snapshot
Staging, intermediate, and marts pattern:
- Staging cleans raw data
- Intermediate adds business logic
- Marts prepare data for reports
- Each layer builds on the previous
- Ensures clean, enriched, and usable data
Full Transcript
This visual execution shows how data moves through the staging, intermediate, and marts pattern in dbt. Raw data is first loaded with inconsistencies. The staging layer cleans and standardizes this data, for example by uppercasing names. Then intermediate models add business logic and enrich the data. Finally, data marts aggregate and prepare the data for business users and reports. This layered approach ensures data is clean, reliable, and ready for analysis. The execution table traces each step, showing inputs and outputs. Variable tracking highlights how data changes at each stage. Key moments clarify why each layer is important. The quiz tests understanding of these transformations and their order.