diff --git a/pipeline/dbt/macros/domain/checks/check_service.sql b/pipeline/dbt/macros/domain/checks/check_service.sql index 2288f7fc8..db2e3553e 100644 --- a/pipeline/dbt/macros/domain/checks/check_service.sql +++ b/pipeline/dbt/macros/domain/checks/check_service.sql @@ -52,16 +52,7 @@ BEGIN ("modes_accueil", "modes_accueil IS NULL OR modes_accueil <@ ARRAY(SELECT m.value FROM " ~ ref('modes_accueil') ~ "AS m)"), ("modes_orientation_accompagnateur", "modes_orientation_accompagnateur IS NULL OR modes_orientation_accompagnateur <@ ARRAY(SELECT m.value FROM " ~ ref('modes_orientation_accompagnateur') ~ "AS m)"), ("modes_orientation_beneficiaire", "modes_orientation_beneficiaire IS NULL OR modes_orientation_beneficiaire <@ ARRAY(SELECT m.value FROM " ~ ref('modes_orientation_beneficiaire') ~ "AS m)"), - ( - "zone_diffusion_code", - "zone_diffusion_code IS NULL - OR zone_diffusion_type = 'pays' - OR zone_diffusion_type = 'region' AND zone_diffusion_code IN (SELECT code FROM " ~ ref('stg_decoupage_administratif__regions') ~ ") - OR zone_diffusion_type = 'departement' AND zone_diffusion_code IN (SELECT code FROM " ~ ref('stg_decoupage_administratif__departements') ~ ") - OR zone_diffusion_type = 'epci' AND zone_diffusion_code IN (SELECT code FROM " ~ ref('stg_decoupage_administratif__epcis') ~ ") - OR zone_diffusion_type = 'commune' AND zone_diffusion_code IN (SELECT code FROM " ~ ref('stg_decoupage_administratif__communes') ~ ") - " - ), + ("zone_diffusion_code", "zone_diffusion_code IS NULL OR zone_diffusion_code ~ '^(\d{9}|\w{5}|\w{2,3}|\d{2})$'"), ("zone_diffusion_type", "zone_diffusion_type IS NULL OR zone_diffusion_type IN (SELECT t.value FROM " ~ ref('zones_de_diffusion_types') ~ "AS t)"), ] %} diff --git a/pipeline/dbt/models/intermediate/_models.yml b/pipeline/dbt/models/intermediate/_models.yml index 6b237a8a0..58723ce53 100644 --- a/pipeline/dbt/models/intermediate/_models.yml +++ b/pipeline/dbt/models/intermediate/_models.yml @@ -53,18 +53,28 @@ models: to: ref('stg_decoupage_administratif__regions') field: code where: "zone_diffusion_type = 'region'" + # TODO(vmttn): prevent false codes from being propagated downstream + # and set back severity to error + config: + severity: warn - relationships: to: ref('stg_decoupage_administratif__departements') field: code where: "zone_diffusion_type = 'departement'" + config: + severity: warn - relationships: to: ref('stg_decoupage_administratif__epcis') field: code where: "zone_diffusion_type = 'epci'" + config: + severity: warn - relationships: to: ref('stg_decoupage_administratif__communes') field: code where: "zone_diffusion_type = 'commune'" + config: + severity: warn - name: int__union_structures__enhanced