generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/nb_menages #197
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
Feat/nb_menages #197
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
53b3b6a
config2
Victorien-M 945112a
Modifications to population_nb_menages NOT WORKING
samibtorres a97df83
Updated model names to match with SQL files
samibtorres 774c2e8
Fixed nb menages silver layer. Added gold layer.
ThomGram f5e8fa5
Added niveau geo
ThomGram 10c8286
Added silver models for nb menages so we aggregate at the region and …
ThomGram 4f58c42
Merge branch 'main' into nb_menages
ThomGram 97eefba
Update dbt_odis/models/bronze/_odis_bronze__models.yml
ThomGram 6ac5e95
Added year at bronze level. Changed view name. Removed obsolete layers.
ThomGram b5ff88b
Added table de passage insee as a seed. The table allows to update co…
ThomGram 198c487
Removed reference to table passage insee codgeo in medallion layers, …
ThomGram 383e93f
Fixed seeds. Added test to check that we can apply the table de passa…
ThomGram a1737ed
Merge branch 'main' into nb_menages
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
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 |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| {{ config( | ||
| tags = ['bronze', 'population'], | ||
| alias='vw_population_menages_2021' | ||
| alias='vw_population_nb_menages' | ||
| ) | ||
| }} | ||
|
|
||
| select | ||
| {{ dbt_utils.star(from=source('bronze', 'population_menages_td_men1_2021')) }} | ||
| from {{ source('bronze', 'population_menages_td_men1_2021') }} | ||
| {% set local_year = '2021' %} | ||
|
|
||
| with population_nb_menages as | ||
| ( | ||
| select {{ dbt_utils.star(from=source('bronze', 'population_menages_td_men1_2021')) }}, | ||
| '{{ local_year }}' as "year" | ||
| from {{ source('bronze', 'population_menages_td_men1_2021') }} | ||
| ) | ||
|
|
||
| select * from population_nb_menages | ||
ThomGram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| {{ config( | ||
| tags = ['gold', 'population', 'nb_menages'], | ||
| ) | ||
| }} | ||
|
|
||
| select * from {{ref('silver_population_menages')}} | ||
| union all | ||
| select * from {{ref('silver_population_menages_departement')}} | ||
| union all | ||
| select * from {{ref('silver_population_menages_region')}} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{ config( | ||
| tags = ['silver', 'population'], | ||
| alias='silver_population_menages' | ||
| ) | ||
| }} | ||
|
|
||
| with population_nb_menages as ( | ||
| select | ||
| coalesce(passage."Code Courant Officiel", pop."CODGEO") as codgeo, | ||
ThomGram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pop.year, | ||
| SUM(pop."NB") as nb_menages, | ||
| SUM(pop."NPERC" * pop."NB") / nullif(SUM(pop."NB"),0) as nb_occ_Moyen, | ||
| 'COM' as niveau_geo | ||
| from {{ ref('population_menages_2021') }} pop | ||
| left join {{ ref('geocodes_passage_annuel') }} passage | ||
| on pop."CODGEO" = passage."Ancien Code Officiel" | ||
| and passage."Niveau" = 'COM' | ||
| where pop."NIVGEO" = 'COM' | ||
| group by coalesce(passage."Code Courant Officiel", pop."CODGEO"), pop.year | ||
| ) | ||
|
|
||
| select * from population_nb_menages | ||
ThomGram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
20 changes: 20 additions & 0 deletions
20
dbt_odis/models/silver/silver_population_menages_departement.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,20 @@ | ||
| {{ config( | ||
| tags = ['silver', 'population'], | ||
| alias='silver_population_menages_departement' | ||
| ) | ||
| }} | ||
|
|
||
| with population_nb_menages_dept as ( | ||
| select | ||
| geo."CODDEP" as codgeo, | ||
wipgarden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| year, | ||
| SUM(pop."NB") as nb_menages, | ||
| SUM(pop."NPERC" * pop."NB") / nullif(SUM(pop."NB"),0) as nb_occ_Moyen, | ||
| 'DEP' as niveau_geo | ||
| from {{ ref('population_menages_2021') }} pop | ||
| inner join {{ ref('com_dep_reg') }} geo on pop."CODGEO" = geo."CODGEO" | ||
wipgarden marked this conversation as resolved.
Show resolved
Hide resolved
ThomGram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| where pop."NIVGEO" = 'COM' | ||
| group by geo."CODDEP", year | ||
| ) | ||
|
|
||
| select * from population_nb_menages_dept | ||
20 changes: 20 additions & 0 deletions
20
dbt_odis/models/silver/silver_population_menages_region.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,20 @@ | ||
| {{ config( | ||
| tags = ['silver', 'population'], | ||
| alias='silver_population_menages_region' | ||
| ) | ||
| }} | ||
|
|
||
| with population_nb_menages_reg as ( | ||
| select | ||
| 'reg' || geo."CODREG" as codgeo, | ||
| year, | ||
| SUM(pop."NB") as nb_menages, | ||
| SUM(pop."NPERC" * pop."NB") / nullif(SUM(pop."NB"),0) as nb_occ_Moyen, | ||
| 'REG' as niveau_geo | ||
| from {{ ref('population_menages_2021') }} pop | ||
| inner join {{ ref('com_dep_reg') }} geo on pop."CODGEO" = geo."CODGEO" | ||
| where pop."NIVGEO" = 'COM' | ||
| group by geo."CODREG", year | ||
| ) | ||
|
|
||
| select * from population_nb_menages_reg |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.