diff --git a/pipeline/dbt/models/staging/sources/mediation_numerique/stg_mediation_numerique__structures.sql b/pipeline/dbt/models/staging/sources/mediation_numerique/stg_mediation_numerique__structures.sql index b6092a8c3..87c11888c 100644 --- a/pipeline/dbt/models/staging/sources/mediation_numerique/stg_mediation_numerique__structures.sql +++ b/pipeline/dbt/models/staging/sources/mediation_numerique/stg_mediation_numerique__structures.sql @@ -4,29 +4,32 @@ WITH source AS ( final AS ( SELECT - _di_source_id AS "_di_source_id", - CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'thematiques', 'null'))) AS TEXT []) AS "thematiques", - CAST((data ->> 'longitude') AS FLOAT) AS "longitude", - CAST((data ->> 'latitude') AS FLOAT) AS "latitude", - CAST((data ->> 'date_maj') AS TIMESTAMP WITH TIME ZONE) AS "date_maj", - CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'labels_nationaux', 'null'))) AS TEXT []) AS "labels_nationaux", - CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'labels_autres', 'null'))) AS TEXT []) AS "labels_autres", - data ->> 'id' AS "id", - data ->> 'nom' AS "nom", - NULLIF(data ->> 'siret', REPEAT('0', 14)) AS "siret", - data ->> 'source' AS "source", - NULLIF(TRIM(data ->> 'adresse'), '') AS "adresse", - NULLIF(TRIM(data ->> 'commune'), '') AS "commune", - NULLIF(TRIM(data ->> 'courriel'), '') AS "courriel", - data ->> 'site_web' AS "site_web", - NULLIF(TRIM(data ->> 'telephone'), '') AS "telephone", - data ->> 'code_postal' AS "code_postal", - data ->> 'code_insee' AS "code_insee", - data ->> 'horaires_ouverture' AS "horaires_ouverture", - data ->> 'typologie' AS "typologie", - data ->> 'presentation_resume' AS "presentation_resume", - data ->> 'accessibilite' AS "accessibilite", - data ->> 'presentation_detail' AS "presentation_detail" + _di_source_id AS "_di_source_id", + CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'thematiques', 'null'))) AS TEXT []) AS "thematiques", + CAST((data ->> 'longitude') AS FLOAT) AS "longitude", + CAST((data ->> 'latitude') AS FLOAT) AS "latitude", + CAST((data ->> 'date_maj') AS TIMESTAMP WITH TIME ZONE) AS "date_maj", + -- SOURCEFIX(2024-10-14) + ARRAY_REMOVE(CAST(ARRAY( + SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'labels_nationaux', 'null')) + ) AS TEXT []), 'sud-labs') AS "labels_nationaux", + CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(NULLIF(data -> 'labels_autres', 'null'))) AS TEXT []) AS "labels_autres", + data ->> 'id' AS "id", + data ->> 'nom' AS "nom", + NULLIF(data ->> 'siret', REPEAT('0', 14)) AS "siret", + data ->> 'source' AS "source", + NULLIF(TRIM(data ->> 'adresse'), '') AS "adresse", + NULLIF(TRIM(data ->> 'commune'), '') AS "commune", + NULLIF(TRIM(data ->> 'courriel'), '') AS "courriel", + data ->> 'site_web' AS "site_web", + NULLIF(TRIM(data ->> 'telephone'), '') AS "telephone", + data ->> 'code_postal' AS "code_postal", + data ->> 'code_insee' AS "code_insee", + data ->> 'horaires_ouverture' AS "horaires_ouverture", + data ->> 'typologie' AS "typologie", + data ->> 'presentation_resume' AS "presentation_resume", + data ->> 'accessibilite' AS "accessibilite", + data ->> 'presentation_detail' AS "presentation_detail" FROM source WHERE data ->> 'source' != 'dora'