Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pipeline): force relation adresses/geocodages #301

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pipeline/dbt/models/intermediate/int__geocodages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
config(
materialized="incremental",
unique_key="adresse_id",
post_hook=[
"
-- adresses can be deleted by the provider, or by us.
-- in both cases, deleting the corresponding geocodages is required
-- to ensure that the relationship between adresses and geocodages stands
WITH deleted_adresses AS (
SELECT geocodages.adresse_id
FROM {{ this }} AS geocodages
LEFT JOIN {{ ref('int__union_adresses') }} AS adresses ON geocodages.adresse_id = adresses._di_surrogate_id
WHERE adresses._di_surrogate_id IS NULL
)
DELETE FROM {{ this }} WHERE {{ this }}.adresse_id IN (SELECT adresse_id FROM deleted_adresses)"
]
)
}}

Expand Down
Loading