Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change relationships schema test to use LOJ instead of not in #799

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions dbt/include/global_project/macros/schema_tests/relationships.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@

{% macro test_relationships(model, field, to, from) %}


select count(*)
from (

select
{{ from }} as id

from {{ model }}
where {{ from }} is not null
and {{ from }} not in (select {{ field }}
from {{ to }})

t1.{{ from }}
from {{ model }} t1
left outer join {{ to }} t2
on t1.{{ from }} = t2.{{ field }}
where t1.{{ from }} is not null
and t2.{{ field }} is null
) validation_errors

{% endmacro %}