Modelling correctness · rule downstream-depends-on-source
dbt marts that read raw sources directly
A Metacenta review checks this under the rule Sources are read through staging, not directly by marts. Everything below applies whether or not you ever commission one.
What this rule checks
This rule flags intermediate and marts models that read a source() directly, with no staging model between. A mart doing this is medium severity; an intermediate model is low. If no model's path places it in a layer, the rule declines.
Why it matters
The renaming and casting that staging does once has either not happened or is repeated here. Two models can then disagree about the same raw column. A mart is rated higher because stakeholders read it directly.
How to fix it
Keep reporting tables off raw data. Add a staging model over each source, and point the model at it with ref().
Before:
-- models/marts/fct_orders.sql
select id as order_id, amount / 100.0 as amount
from {{ source('shop', 'orders') }}
After:
-- models/marts/fct_orders.sql
select order_id, amount
from {{ ref('stg_shop__orders') }}
When it is fine to leave
A source already clean at the point of load, with the column names and types you want, gains little from a staging model that only selects it. Say so in the source's description, and stage it when that changes.
What we need to check it
manifest.json alone. Layers come from folder names in each model's path. A project with no sources, or no intermediate or marts models, is not judged here.
Published rules it corresponds to
dbt_project_evaluator, rule fct_marts_or_intermediate_dependent_on_source. Ours checks the same condition and threshold.
This means our check corresponds to their rule. It does not mean the publisher reviewed or endorses it.