Skip to content

Commit

Permalink
Fix dbt 'relationships' generic test for ClickHouse ClickHouse#19
Browse files Browse the repository at this point in the history
  • Loading branch information
artamoshin committed Oct 3, 2021
1 parent 07b94e2 commit 002e55c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dbt/include/clickhouse/macros/generic_tests/relationships.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% macro clickhouse__test_relationships(model, column_name, to, field) %}

with child as (
select {{ column_name }} as from_field
from {{ model }}
where {{ column_name }} is not null
),

parent as (
select {{ field }} as to_field
from {{ to }}
)

select
from_field

from child
left join parent
on child.from_field = parent.to_field

where parent.to_field is null
settings join_use_nulls = 1

{% endmacro %}

0 comments on commit 002e55c

Please sign in to comment.