-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pipeline): cleanup pii detection
* Simplify personal email detection. More false positives in favour of simplicity and speed. * Add unit tests
- Loading branch information
Showing
15 changed files
with
142 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: int__plausible_personal_emails | ||
|
||
- name: int__union_adresses | ||
data_tests: | ||
- check_adresse: | ||
|
@@ -183,8 +181,29 @@ models: | |
min_value: 0 | ||
max_value: 1 | ||
|
||
- name: int__courriel_personnels | ||
columns: | ||
- name: courriel | ||
data_tests: | ||
- not_null | ||
- dbt_utils.not_empty_string | ||
|
||
unit_tests: | ||
- name: test_courriels_personnels | ||
model: int__courriels_personnels | ||
given: | ||
- input: ref('int__union_contacts') | ||
rows: | ||
- {courriel: [email protected]} | ||
- {courriel: [email protected]} | ||
- {courriel: [email protected]} | ||
- input: ref('stg_insee__prenoms') | ||
rows: | ||
- {prenom: jean} | ||
expect: | ||
rows: | ||
- {courriel: [email protected]} | ||
|
||
- name: test_geocodages_full_refresh_mode | ||
model: int__geocodages | ||
overrides: | ||
|
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
pipeline/dbt/models/intermediate/extra/int_extra__insee_prenoms_filtered.sql
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
pipeline/dbt/models/intermediate/int__courriels_personnels.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
WITH contacts AS ( | ||
SELECT * FROM {{ ref('int__union_contacts') }} | ||
), | ||
|
||
insee_prenoms AS ( | ||
SELECT * FROM {{ ref('stg_insee__prenoms') }} | ||
), | ||
|
||
final AS ( | ||
SELECT DISTINCT contacts.courriel | ||
FROM contacts | ||
INNER JOIN insee_prenoms | ||
ON STARTS_WITH(contacts.courriel, (insee_prenoms.prenom || '.')) | ||
WHERE | ||
-- focus on mainstream email providers | ||
SPLIT_PART(SPLIT_PART(contacts.courriel, '@', 2), '.', -2) -- 2nd level domain | ||
IN ( | ||
'wanadoo', | ||
'orange', | ||
'gmail', | ||
'free', | ||
'laposte', | ||
'yahoo', | ||
'hotmail', | ||
'nordnet', | ||
'sfr', | ||
'outlook', | ||
'laposte' | ||
) | ||
-- ignore common patterns for non personal emails | ||
AND NOT SPLIT_PART(contacts.courriel, '@', 1) ~ 'mairie|commune|adil|services|ccas' | ||
) | ||
|
||
SELECT * FROM final |
56 changes: 0 additions & 56 deletions
56
pipeline/dbt/models/intermediate/int__plausible_personal_emails.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: stg_insee__prenoms | ||
columns: | ||
- name: prenom | ||
data_tests: | ||
- unique | ||
- not_null | ||
- dbt_utils.not_empty_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: insee | ||
schema: insee | ||
tables: | ||
- name: etat_civil_prenoms | ||
- name: sirene_etablissement_historique | ||
- name: sirene_etablissement_succession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
WITH source AS ( | ||
SELECT * FROM {{ source('insee', 'etat_civil_prenoms') }} | ||
), | ||
|
||
cleaned AS ( | ||
SELECT | ||
CASE sexe::INT | ||
WHEN 1 THEN 'masculin' | ||
WHEN 2 THEN 'feminin' | ||
END AS "sexe", | ||
LOWER(preusuel) AS "prenom", | ||
annais::INT AS "annee_naissance", | ||
nombre | ||
FROM source | ||
WHERE preusuel != '_PRENOMS_RARES' | ||
), | ||
|
||
filtered AS ( | ||
SELECT prenom | ||
FROM cleaned | ||
WHERE | ||
LENGTH(prenom) > 2 | ||
AND prenom !~* 'saint' | ||
GROUP BY 1 | ||
HAVING SUM(nombre) > 100 | ||
ORDER BY 1 ASC | ||
) | ||
|
||
SELECT * FROM filtered |