Files
dbt-project-evaluator/models/audit/dag/fct_source_fanout.sql

28 lines
654 B
SQL

-- this model finds cases where a source is used in multiple direct downstream models
with direct_source_relationships as (
select
*
from {{ ref('stg_dag_relationships') }}
where distance = 1
and parent_type = 'source'
),
source_fanout as (
select
parent,
count(*)
from direct_source_relationships
group by 1
having count(*) > 1
),
final as (
select
direct_source_relationships.*
from direct_source_relationships
inner join source_fanout
on direct_source_relationships.parent = source_fanout.parent
order by direct_source_relationships.parent
)
select * from final