generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/190 presentation population communes #194
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5a1078a
Added INSEE Melodi Source to get population at the communes' level.
ThomGram f19c48c
Changed name from presentation_page to presentation for consistency.
ThomGram 107a7a3
Fixed naming convention so we drop 'page' everywhere. Fixed bronze pr…
ThomGram 718a30d
Added silver layer. Keep only last 5 char for geo as geocode, only ke…
ThomGram 1e39dee
Added gold layer for presentation_population_communes
ThomGram 8d541ea
Fixed Melodi API request. When page=1 is provided, all pages are corr…
ThomGram bb8e725
Fixed time period. Now that the extraction is fixed, it is taking age…
ThomGram 2f31819
Added tests on gold_presentation_population_communes to ensure that m…
ThomGram 1f16f11
Added docs and test for gold_presentation_population_communes. Made a…
ThomGram 32c7c3d
Added test on 2022 top 50 cities: check that population is consistant…
ThomGram ad6f80e
Merge branch 'main' into Feat/190-presentation_population_communes
ThomGram 7b063ce
Fixed codgeon column name consistency. Removed bronze and silver laye…
ThomGram de9efe7
Fixed codgeo column name.
ThomGram d00008b
Merge branch 'main' into Feat/190-presentation_population_communes
ThomGram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
22 changes: 0 additions & 22 deletions
22
dbt_odis/models/bronze/presentation_page_population_communes.sql
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
dbt_odis/models/bronze/presentation_population_communes.sql
This file contains hidden or 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,21 @@ | ||
| {{ config( | ||
| tags = ['bronze', 'presentation'], | ||
| alias = 'vw_presentation_population_communes' | ||
| ) | ||
| }} | ||
|
|
||
|
|
||
| with population_communes as | ||
| ( | ||
| select | ||
| (data::jsonb)->'measures' -> 'OBS_VALUE_NIVEAU' ->> 'value' as value, | ||
| (data::jsonb)->'dimensions' ->> 'AGE' as "AGE", | ||
| (data::jsonb)->'dimensions' ->> 'GEO' as "GEO", | ||
| (data::jsonb)->'dimensions' ->> 'SEX' as "SEX", | ||
| (data::jsonb)->'dimensions' ->> 'RP_MEASURE' as "RP_MEASURE", | ||
| (data::jsonb)->'dimensions' ->> 'TIME_PERIOD' as "TIME_PERIOD", | ||
| created_at | ||
| from {{ source('bronze', 'presentation_population_communes') }} | ||
| ) | ||
|
|
||
| select * from population_communes |
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
dbt_odis/models/gold/gold_presentation_population_communes.sql
This file contains hidden or 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,7 @@ | ||
| {{ config( | ||
| tags = ['gold', 'population', 'presentation'], | ||
| alias='vw_presentation_population_communes_gold', | ||
| ) }} | ||
|
|
||
|
|
||
| select codgeo, population_totale, year from {{ ref("stg_presentation_population_communes") }} |
24 changes: 24 additions & 0 deletions
24
dbt_odis/models/silver/stg_presentation_population_communes.sql
This file contains hidden or 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,24 @@ | ||
| {{ config( | ||
ThomGram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tags = ['silver', 'population', 'presentation'], | ||
| alias='vw_presentation_population_communes_stg', | ||
| materialized='view' | ||
| ) }} | ||
|
|
||
| with cleaned as ( | ||
| select | ||
| split_part("GEO", '-', 3) as codgeo, | ||
ThomGram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "value"::float as population, | ||
| "TIME_PERIOD"::integer as year, | ||
| "GEO" as geo_original | ||
| from {{ ref("presentation_population_communes") }} | ||
| where ("GEO" like '%COM-%') | ||
| and "AGE" = '_T' | ||
| and "SEX" = '_T' | ||
| and "RP_MEASURE" = 'POP' | ||
| ) | ||
|
|
||
| select | ||
| codgeo, | ||
| population as population_totale, | ||
| year | ||
| from cleaned | ||
This file contains hidden or 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 hidden or 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,51 @@ | ||
| AGE;GEO;GEO_OBJECT;RP_MEASURE;SEX;TIME_PERIOD;OBS_VALUE | ||
ThomGram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _T;75056;COM;POP;_T;2022;2113705.0 | ||
| _T;13055;COM;POP;_T;2022;877215.0 | ||
| _T;69123;COM;POP;_T;2022;520774.0 | ||
| _T;31555;COM;POP;_T;2022;511684.0 | ||
| _T;06088;COM;POP;_T;2022;353701.0 | ||
| _T;44109;COM;POP;_T;2022;325070.0 | ||
| _T;34172;COM;POP;_T;2022;307101.0 | ||
| _T;67482;COM;POP;_T;2022;291709.0 | ||
| _T;33063;COM;POP;_T;2022;265328.0 | ||
| _T;59350;COM;POP;_T;2022;238695.0 | ||
| _T;35238;COM;POP;_T;2022;227830.0 | ||
| _T;83137;COM;POP;_T;2022;180834.0 | ||
| _T;51454;COM;POP;_T;2022;178478.0 | ||
| _T;42218;COM;POP;_T;2022;172569.0 | ||
| _T;76351;COM;POP;_T;2022;166462.0 | ||
| _T;69266;COM;POP;_T;2022;162207.0 | ||
| _T;21231;COM;POP;_T;2022;159941.0 | ||
| _T;49007;COM;POP;_T;2022;157555.0 | ||
| _T;38185;COM;POP;_T;2022;156389.0 | ||
| _T;97411;COM;POP;_T;2022;156149.0 | ||
| _T;30189;COM;POP;_T;2022;150444.0 | ||
| _T;93066;COM;POP;_T;2022;148907.0 | ||
| _T;13001;COM;POP;_T;2022;147933.0 | ||
| _T;63113;COM;POP;_T;2022;147751.0 | ||
| _T;72181;COM;POP;_T;2022;145182.0 | ||
| _T;29019;COM;POP;_T;2022;140993.0 | ||
| _T;37261;COM;POP;_T;2022;138668.0 | ||
| _T;80021;COM;POP;_T;2022;134780.0 | ||
| _T;74010;COM;POP;_T;2022;131272.0 | ||
| _T;87085;COM;POP;_T;2022;129754.0 | ||
| _T;57463;COM;POP;_T;2022;121695.0 | ||
| _T;66136;COM;POP;_T;2022;120996.0 | ||
| _T;92012;COM;POP;_T;2022;120205.0 | ||
| _T;25056;COM;POP;_T;2022;120057.0 | ||
| _T;45234;COM;POP;_T;2022;116344.0 | ||
| _T;76540;COM;POP;_T;2022;116331.0 | ||
| _T;93048;COM;POP;_T;2022;110758.0 | ||
| _T;14118;COM;POP;_T;2022;108398.0 | ||
| _T;95018;COM;POP;_T;2022;107135.0 | ||
| _T;97415;COM;POP;_T;2022;106220.0 | ||
| _T;68224;COM;POP;_T;2022;104924.0 | ||
| _T;54395;COM;POP;_T;2022;104387.0 | ||
| _T;59512;COM;POP;_T;2022;99507.0 | ||
| _T;59599;COM;POP;_T;2022;99160.0 | ||
| _T;92050;COM;POP;_T;2022;98119.0 | ||
| _T;94081;COM;POP;_T;2022;95282.0 | ||
| _T;94028;COM;POP;_T;2022;92859.0 | ||
| _T;84007;COM;POP;_T;2022;91760.0 | ||
| _T;92004;COM;POP;_T;2022;91457.0 | ||
| _T;92025;COM;POP;_T;2022;90692.0 | ||
This file contains hidden or 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,23 @@ | ||
| {% test assert_big_cities_exist(model, column_name) %} | ||
|
|
||
| with big_cities as ( | ||
| select '75056' as codgeo | ||
| union all | ||
| select '13055' | ||
| union all | ||
| select '69123' | ||
| ), | ||
|
|
||
| missing as ( | ||
| select | ||
| bc.codgeo | ||
| from big_cities bc | ||
| left join {{ model }} model | ||
| on bc.codgeo = model.{{column_name}} | ||
| where model.{{column_name}} is null | ||
| ) | ||
|
|
||
| -- Le test échoue si le code commune de Paris, Marseille ou Lyon manque | ||
| select * from missing | ||
|
|
||
| {% endtest %} |
This file contains hidden or 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,19 @@ | ||
|
|
||
| with insee_data as ( | ||
| select * from {{ ref('insee_top_50_communes_par_habitants') }} | ||
| ) | ||
|
|
||
| select | ||
| id."GEO" as codgeo, | ||
| id."OBS_VALUE" as insee_population, | ||
| model.population_totale as model_population, | ||
| id."OBS_VALUE" / model.population_totale as ratio | ||
| from insee_data id | ||
| left join {{ ref('gold_presentation_population_communes') }} model | ||
| on id."GEO" = model.codgeo | ||
| where model.population_totale is not null and model.year = 2022 | ||
| and model.population_totale > 0 | ||
| and ( | ||
| id."OBS_VALUE" / model.population_totale < 0.9 | ||
| or id."OBS_VALUE" / model.population_totale > 1.1 | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.