Staging is the first dbt layer above raw sources. Staging models usually have a 1:1 relationship with source tables and do light, reversible cleanup.
Typical staging work
- Rename columns to clear analytics names
- Cast types (
string→timestamp, cents → dollars) - Trim/standardize simple fields
- Soft delete filters if clearly marked
- Pass-through of source keys
What staging usually does NOT do
- Heavy business definitions ("active customer")
- Wide multi-source joins into final facts
- Complex windowed metrics
source(raw.orders) → stg_orders → int_* → fct_orders / dim_*
Example
-- models/staging/stg_stripe__payments.sql
with src as (
select * from {{ source('stripe', 'payments') }}
)
select
id as payment_id,
order_id,
cast(amount as numeric) / 100.0 as amount,
cast(created as timestamp) as created_at
from srcConventions
Many teams name files stg_<source>__<table>.sql and materialize staging as views.
Interview tip: "Staging is the anti-corruption layer: stabilize names and types once, so marts do not all re-cast raw junk."