diff --git a/pipeline/dbt/macros/domain/checks/check_service.sql b/pipeline/dbt/macros/domain/checks/check_service.sql index db2e3553e..2288f7fc8 100644 --- a/pipeline/dbt/macros/domain/checks/check_service.sql +++ b/pipeline/dbt/macros/domain/checks/check_service.sql @@ -52,7 +52,16 @@ 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_code ~ '^(\d{9}|\w{5}|\w{2,3}|\d{2})$'"), + ( + "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_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 58723ce53..6b237a8a0 100644 --- a/pipeline/dbt/models/intermediate/_models.yml +++ b/pipeline/dbt/models/intermediate/_models.yml @@ -53,28 +53,18 @@ 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