-
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.
Feat/better handling hierarchy (#1158)
* fix herarchy and cities Signed-off-by: Raphaël Courivaud <[email protected]> * add external communes departements epeci regions Signed-off-by: Raphaël Courivaud <[email protected]> --------- Signed-off-by: Raphaël Courivaud <[email protected]>
- Loading branch information
1 parent
3fe00a8
commit f7e0409
Showing
18 changed files
with
138 additions
and
34 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 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,9 +1,13 @@ | ||
from .ingest_lovac_ff_s3_asset import import_cerema_ff_lovac_data_from_s3_to_duckdb, setup_s3_connection | ||
from .ingest_postgres_asset import import_postgres_data_from_replica_to_duckdb, setup_replica_db | ||
|
||
from .administrative_cuts import raw_communes, raw_epci, raw_departements, raw_regions | ||
__all__ = [ | ||
"import_postgres_data_from_replica_to_duckdb", | ||
"import_cerema_ff_lovac_data_from_s3_to_duckdb", | ||
"setup_replica_db", | ||
"setup_s3_connection", | ||
"raw_communes", | ||
"raw_epci", | ||
"raw_departements", | ||
"raw_regions", | ||
] |
40 changes: 40 additions & 0 deletions
40
analytics/dagster/src/assets/dwh/ingest/administrative_cuts.py
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,40 @@ | ||
# assets.py | ||
import pandas as pd | ||
from dagster_duckdb import DuckDBResource | ||
from dagster import AssetKey, asset, AssetExecutionContext | ||
|
||
|
||
|
||
@asset(deps=[AssetKey("setup_duckdb")], | ||
group_name="external_seeds") | ||
def raw_communes(context: AssetExecutionContext, duckdb: DuckDBResource): | ||
df = pd.read_json('https://geo.api.gouv.fr/communes') | ||
with duckdb.get_connection() as conn: | ||
conn.execute("CREATE SCHEMA IF NOT EXISTS external;") | ||
conn.execute("CREATE OR REPLACE TABLE external.communes AS SELECT * FROM df") | ||
@asset(deps=[AssetKey("setup_duckdb")], | ||
group_name="external_seeds") | ||
def raw_epci(context: AssetExecutionContext, duckdb: DuckDBResource): | ||
df = pd.read_json('https://geo.api.gouv.fr/epcis') | ||
with duckdb.get_connection() as conn: | ||
conn.execute("CREATE SCHEMA IF NOT EXISTS external;") | ||
conn.execute("CREATE OR REPLACE TABLE external.epci AS SELECT * FROM df") | ||
|
||
|
||
@asset(deps=[AssetKey("setup_duckdb")], | ||
group_name="external_seeds") | ||
def raw_departements(context: AssetExecutionContext, duckdb: DuckDBResource): | ||
df = pd.read_json('https://geo.api.gouv.fr/departements') | ||
with duckdb.get_connection() as conn: | ||
conn.execute("CREATE SCHEMA IF NOT EXISTS external;") | ||
conn.execute("CREATE OR REPLACE TABLE external.departements AS SELECT * FROM df") | ||
|
||
|
||
|
||
@asset(deps=[AssetKey("setup_duckdb")], | ||
group_name="external_seeds") | ||
def raw_regions(context: AssetExecutionContext, duckdb: DuckDBResource): | ||
df = pd.read_json('https://geo.api.gouv.fr/regions') | ||
with duckdb.get_connection() as conn: | ||
conn.execute("CREATE SCHEMA IF NOT EXISTS external;") | ||
conn.execute("CREATE OR REPLACE TABLE external.regions AS SELECT * FROM df") |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ ref('stg_admin_communes') }} |
3 changes: 3 additions & 0 deletions
3
analytics/dbt/models/marts/admin/marts_admin_departements.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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ ref('stg_admin_departements') }} |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ ref('stg_admin_epci') }} |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ ref('stg_admin_regions') }} |
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
36 changes: 18 additions & 18 deletions
36
analytics/dbt/models/marts/public/marts_public_establishments_hierarchy.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
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,7 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: stg_admin_communes | ||
- name: stg_admin_epci | ||
- name: stg_admin_departements | ||
- name: stg_admin_regions |
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 | ||
|
||
sources: | ||
- name: duckdb_raw | ||
schema: external | ||
tables: | ||
- name: communes | ||
- name: epci | ||
- name: departements | ||
- name: regions |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ source ('duckdb_raw', 'communes') }} |
3 changes: 3 additions & 0 deletions
3
analytics/dbt/models/staging/admin/stg_admin_departements.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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ source ('duckdb_raw', 'departements') }} |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ source ('duckdb_raw', 'epci') }} |
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,3 @@ | ||
SELECT | ||
* | ||
FROM {{ source ('duckdb_raw', 'regions') }} |
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