Created
August 15, 2023 20:24
-
-
Save arimbr/b8dc6a37e82a9f84a8e30dbf257a7b7d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| {% macro default__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 | |
| {% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment