Skip to content

Commit

Permalink
feat(rpls): remove duplicated lines
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig committed Dec 19, 2024
1 parent cbdaf34 commit 6f59eb1
Showing 1 changed file with 96 additions and 111 deletions.
207 changes: 96 additions & 111 deletions airflow/include/sql/sparte/models/rpls/rpls_national.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
{{ config(materialized='table') }}

{% set paris = [
'75101',
'75102',
'75103',
'75104',
'75105',
'75106',
'75107',
'75108',
'75109',
'75110',
'75111',
'75112',
'75113',
'75114',
'75115',
'75116',
'75117',
'75118',
'75119',
'75120'
] %}

{% set lyon = [
'69381',
'69382',
'69383',
'69384',
'69385',
'69386',
'69387',
'69388',
'69389'
] %}

{% set marseille = [
'13201',
'13202',
'13203',
'13204',
'13205',
'13206',
'13207',
'13208',
'13209',
'13210',
'13211',
'13212',
'13213',
'13214',
'13215',
'13216'
] %}

{% set mayotte = [
'97607',
'97611',
'97605',
'97614',
'97617',
'97610',
'97616',
'97609',
'97602',
'97608',
'97606',
'97603',
'97615',
'97604'
] %}

with raw_data as (
SELECT
"Commune (DEP)" as commune_name,
Expand Down Expand Up @@ -199,69 +270,19 @@ SELECT
)
SELECT * FROM raw_data
WHERE commune_code not in (
-- Paris
'75101',
'75102',
'75103',
'75104',
'75105',
'75106',
'75107',
'75108',
'75109',
'75110',
'75111',
'75112',
'75113',
'75114',
'75115',
'75116',
'75117',
'75118',
'75119',
'75120',
-- Lyon
'69381',
'69382',
'69383',
'69384',
'69385',
'69386',
'69387',
'69388',
'69389',
-- Marseille
'13201',
'13202',
'13203',
'13204',
'13205',
'13206',
'13207',
'13208',
'13209',
'13210',
'13211',
'13212',
'13213',
'13214',
'13215',
'13216',
-- Mayotte
'97607',
'97611',
'97605',
'97614',
'97617',
'97610',
'97616',
'97609',
'97602',
'97608',
'97606',
'97603',
'97615',
'97604'
{% for code in paris %}
'{{ code }}',
{% endfor %}
{% for code in lyon %}
'{{ code }}',
{% endfor %}
{% for code in marseille %}
'{{ code }}',
{% endfor %}
{% for code in mayotte %}
'{{ code }}'
{% if not loop.last %},{% endif %}
{% endfor %}
)
UNION
SELECT
Expand All @@ -273,27 +294,10 @@ SELECT
FROM
raw_data
WHERE commune_code in (
-- Paris
'75101',
'75102',
'75103',
'75104',
'75105',
'75106',
'75107',
'75108',
'75109',
'75110',
'75111',
'75112',
'75113',
'75114',
'75115',
'75116',
'75117',
'75118',
'75119',
'75120'
{% for code in paris %}
'{{ code }}'
{% if not loop.last %},{% endif %}
{% endfor %}
)
UNION
SELECT
Expand All @@ -306,16 +310,10 @@ FROM
raw_data
WHERE
commune_code in (
-- Paris
'69381',
'69382',
'69383',
'69384',
'69385',
'69386',
'69387',
'69388',
'69389'
{% for code in lyon %}
'{{ code }}'
{% if not loop.last %},{% endif %}
{% endfor %}
)
UNION
SELECT
Expand All @@ -327,21 +325,8 @@ SELECT
FROM
raw_data
WHERE commune_code in (
-- Marseille
'13201',
'13202',
'13203',
'13204',
'13205',
'13206',
'13207',
'13208',
'13209',
'13210',
'13211',
'13212',
'13213',
'13214',
'13215',
'13216'
{% for code in marseille %}
'{{ code }}'
{% if not loop.last %},{% endif %}
{% endfor %}
)

0 comments on commit 6f59eb1

Please sign in to comment.