From 9e98106144aae40fabbf44d298c3b10cee4f342d Mon Sep 17 00:00:00 2001 From: Yannick Passarelli Date: Thu, 3 Oct 2024 15:49:17 +0200 Subject: [PATCH] fix dora services check errors adding a test test add test chore(pipeline) : Fix unit tests Note : the code was incorrect, thank us for unit testing it. Side note : ARRAY is unsupported for the `dict` data type in unit tests, currently, so we have to use SQL, meaning we also have to define each and every field out there. Other side note : as a side effect, this checks that the 'profils' field is made empty when going from 'stg' to 'int' layer with DORA services. dropping the tests fix conflict fix rebase fix typo --- .../intermediate/sources/dora/int_dora__services.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pipeline/dbt/models/intermediate/sources/dora/int_dora__services.sql b/pipeline/dbt/models/intermediate/sources/dora/int_dora__services.sql index ad5b2f8a..eab730ab 100644 --- a/pipeline/dbt/models/intermediate/sources/dora/int_dora__services.sql +++ b/pipeline/dbt/models/intermediate/sources/dora/int_dora__services.sql @@ -30,7 +30,12 @@ final AS ( services.modes_accueil AS "modes_accueil", services.modes_orientation_accompagnateur AS "modes_orientation_accompagnateur", services.modes_orientation_accompagnateur_autres AS "modes_orientation_accompagnateur_autres", - services.modes_orientation_beneficiaire AS "modes_orientation_beneficiaire", + /* The 'professionnel' condition is not included in the associated seed. Therefore, after discussing it, + we decided to convert it into a null value to still take it in account in our tables and avoid a global schema change */ + CASE + WHEN 'professionnel' = ANY(services.modes_orientation_beneficiaire) THEN NULL + ELSE services.modes_orientation_beneficiaire + END AS "modes_orientation_beneficiaire", services.modes_orientation_beneficiaire_autres AS "modes_orientation_beneficiaire_autres", services.nom AS "nom", services.presentation_resume AS "presentation_resume", @@ -59,7 +64,10 @@ final AS ( services.contact_nom_prenom AS "contact_nom_prenom", services.courriel AS "courriel", services.telephone AS "telephone", - ARRAY[services.frais] AS "frais" + CASE + WHEN services.frais IS NULL THEN NULL + ELSE ARRAY[services.frais] + END AS "frais" FROM services )