Modelling correctness · rule multiple-sources-joined
dbt models reading several raw sources at once
A Metacenta review checks this under the rule A model joins at most one raw source. Everything below applies whether or not you ever commission one.
What this rule checks
This rule flags any model that depends on two or more source() tables. It reads the model's declared dependencies, not its SQL, so a union counts as much as a join. It does not need a layered project.
Why it matters
The join uses whatever the source systems call their keys, with no staging model to absorb a rename. An upstream column change then breaks this model, rather than one staging model.
How to fix it
Clean each raw source on its own before combining them. Stage each source in its own model, then join the staged models.
Before:
select o.id, c.email_hash
from {{ source('shop', 'orders') }} as o
join {{ source('shop', 'customers') }} as c
on c.id = o.cust_id
After:
select o.order_id, c.email_hash
from {{ ref('stg_shop__orders') }} as o
join {{ ref('stg_shop__customers') }} as c
on c.customer_id = o.customer_id
When it is fine to leave
A staging model that unions one table from several identical sources, such as one schema per region, is a common and sound pattern. Keep that union in staging and describe it.
What we need to check it
manifest.json alone. We read each model's depends_on, so the rule works in flat and layered projects alike.
Published rules it corresponds to
dbt_project_evaluator, rule fct_multiple_sources_joined. 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.