Skip to content

Commit cecdd1a

Browse files
authored
Merge pull request #1518 from MTES-MCT/feat-dbt-has-all-lands
Ajout du test has_all_lands sur la table for_app_land
2 parents 9985963 + c68f427 commit cecdd1a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

airflow/include/sql/sparte/models/for_app/administration/for_app_land.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@ models:
192192
values:
193193
- "true"
194194
- "false"
195+
data_tests:
196+
- has_all_lands
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% test has_all_lands(model, exceptions=[], excluded_land_types=[]) %}
2+
3+
select
4+
land.land_id,
5+
land.land_type
6+
from {{ ref('land') }} as land
7+
left join (
8+
select distinct land_id, land_type from {{ model }}
9+
) as model
10+
on model.land_id = land.land_id
11+
and model.land_type = land.land_type
12+
where model.land_id is null
13+
{% if excluded_land_types %}
14+
and land.land_type not in (
15+
{% for lt in excluded_land_types %}
16+
'{{ lt }}'{% if not loop.last %},{% endif %}
17+
{% endfor %}
18+
)
19+
{% endif %}
20+
{% if exceptions %}
21+
and (land.land_id, land.land_type) not in (
22+
{% for e in exceptions %}
23+
('{{ e.land_id }}', '{{ e.land_type }}'){% if not loop.last %},{% endif %}
24+
{% endfor %}
25+
)
26+
{% endif %}
27+
28+
{% endtest %}

0 commit comments

Comments
 (0)