-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bc8826
commit 0d666e8
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
dbt/include/clickhouse/macros/schema_tests/relationships.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |