From 0d666e83a528d19daa9ce7bf735268c6a50bc74e Mon Sep 17 00:00:00 2001 From: Dmitriy Sokolov Date: Sat, 9 Oct 2021 14:15:38 +0300 Subject: [PATCH] Fix relationships test #19 --- .../macros/schema_tests/relationships.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 dbt/include/clickhouse/macros/schema_tests/relationships.sql diff --git a/dbt/include/clickhouse/macros/schema_tests/relationships.sql b/dbt/include/clickhouse/macros/schema_tests/relationships.sql new file mode 100644 index 00000000..b756a99c --- /dev/null +++ b/dbt/include/clickhouse/macros/schema_tests/relationships.sql @@ -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 %}