dbt · Extra High-Value

What is staging in dbt?

Easystagingmedallionlayerssources

Interview question

What is the staging layer in a dbt project, and what belongs there?

How to answer

The short answer

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

Example

SQL
-- 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 src

Conventions

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."