Skip to content

Commit 8248b11

Browse files
committed
🐛 Fix for duplicate PKs in stg relationships
1 parent a955400 commit 8248b11

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-- depends on: {{ ref('stg_model_1') }}
2+
-- depends on: {{ ref('stg_model_1') }}
3+
-- depends on: {{ ref('stg_model_1') }}
24
-- depends on: {{ source('source_1', 'table_2') }}
35

46
select 1 as id

macros/unpack/get_relationship_values.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
[
4040
"cast('" ~ node.unique_id ~ "' as " ~ dbt.type_string() ~ ")",
4141
"cast('" ~ parent ~ "' as " ~ dbt.type_string() ~ ")",
42-
"" ~ loop.last ~ ""
42+
"" ~ loop.last ~ "" if node.unique_id.split('.')[0] == 'test' else "FALSE"
4343
]
4444
%}
4545

models/staging/graph/stg_node_relationships.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ final as (
1111
from _base_node_relationships
1212
)
1313

14-
select * from final
14+
-- we need distinct as the graph lists relationships multiple times if they are ref'd multiple times
15+
select distinct * from final

0 commit comments

Comments
 (0)