Skip to content

Commit

Permalink
Merge pull request #742 from MTES-MCT/feat-commune-without-epci
Browse files Browse the repository at this point in the history
feat(for_app_landconsostats): add case for commune without epci
  • Loading branch information
alexisig authored Nov 20, 2024
2 parents 5bcab87 + 77932b2 commit 7dc23ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@
SELECT
commune_code as land_id,
'{{ var('COMMUNE') }}' as land_type,
'{{ var('EPCI') }}' as comparison_level,
commune.epci as comparison_id,
CASE
WHEN commune.epci IS NOT NULL
THEN '{{ var('EPCI') }}'
ELSE '{{ var('NATION') }}'
END as comparison_level,
CASE
WHEN commune.epci IS NOT NULL
THEN commune.epci
ELSE '{{ var('NATION') }}'
END as comparison_id,
{{ fields_to_query }}

FROM
{{ ref('period_consommation_commune') }}
LEFT JOIN
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

models:
- name: for_app_landconsostats
columns:
- name: land_id
data_tests:
- not_null
- name: comparison_id
data_tests:
- not_null
- relationships:
to: ref('for_app_landconsocomparison')
field: land_id

0 comments on commit 7dc23ea

Please sign in to comment.