From ae87c3273263a51ffd637f746ad625045117a5ad Mon Sep 17 00:00:00 2001 From: Valentin Matton Date: Thu, 25 Apr 2024 14:46:08 +0200 Subject: [PATCH] chore(pipeline): add final dimension tables The following changes are scoped to the final models: * clean up unmaintained doc * rename `marts/api` to `marts/inclusion` * rename models to following naming convention * force full-refresh for schema seeds * add unique constraint to schema seeds to be able to set foreign keys * unnest jsonb list columns to new tables, with contracts * enforce contract for marts by default * set indexes using dbt contracts * set foreign keys using dbt contracts --- pipeline/dags/dag_utils/marts.py | 2 +- pipeline/dags/main.py | 2 +- pipeline/dbt/dbt_project.yml | 15 +- ..._inclusion__unnest_jsonb_list_to_table.sql | 18 + pipeline/dbt/models/marts/api/_api_models.yml | 206 --------- pipeline/dbt/models/marts/api/api.md | 15 - pipeline/dbt/models/marts/api/api_service.sql | 40 -- .../marts/inclusion/_inclusion_models.yml | 401 ++++++++++++++++++ .../inclusion/marts_inclusion__services.sql | 20 + .../marts_inclusion__services_frais.sql | 1 + ...arts_inclusion__services_justificatifs.sql | 1 + ...arts_inclusion__services_modes_accueil.sql | 1 + ...vices_modes_orientation_accompagnateur.sql | 1 + ...ervices_modes_orientation_beneficiaire.sql | 1 + .../marts_inclusion__services_pre_requis.sql | 1 + .../marts_inclusion__services_profils.sql | 1 + .../marts_inclusion__services_thematiques.sql | 1 + .../marts_inclusion__services_types.sql | 1 + .../marts_inclusion__structures.sql} | 11 - ...inclusion__structures_labels_nationaux.sql | 1 + ...arts_inclusion__structures_thematiques.sql | 1 + 21 files changed, 464 insertions(+), 277 deletions(-) create mode 100644 pipeline/dbt/macros/marts_inclusion__unnest_jsonb_list_to_table.sql delete mode 100644 pipeline/dbt/models/marts/api/_api_models.yml delete mode 100644 pipeline/dbt/models/marts/api/api.md delete mode 100644 pipeline/dbt/models/marts/api/api_service.sql create mode 100644 pipeline/dbt/models/marts/inclusion/_inclusion_models.yml create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_frais.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_justificatifs.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_accueil.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_accompagnateur.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_beneficiaire.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_pre_requis.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_profils.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_thematiques.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__services_types.sql rename pipeline/dbt/models/marts/{api/api_structure.sql => inclusion/marts_inclusion__structures.sql} (70%) create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_labels_nationaux.sql create mode 100644 pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_thematiques.sql diff --git a/pipeline/dags/dag_utils/marts.py b/pipeline/dags/dag_utils/marts.py index ed0d7de6..8ab78d7e 100644 --- a/pipeline/dags/dag_utils/marts.py +++ b/pipeline/dags/dag_utils/marts.py @@ -23,7 +23,7 @@ def _export_di_dataset_to_s3(logical_date, run_id): # TODO(vmttn): normalize table name after db split table_name = ressource.rstrip("s") key = f"{prefix}{ressource}.parquet" - query = f"SELECT * FROM public.{table_name}" + query = f"SELECT * FROM public_marts.marts_inclusion__{table_name}" logger.info("downloading data from query='%s'", query) df = pg_hook.get_pandas_df(sql=query) diff --git a/pipeline/dags/main.py b/pipeline/dags/main.py index 67db2465..3dee5eff 100644 --- a/pipeline/dags/main.py +++ b/pipeline/dags/main.py @@ -89,7 +89,7 @@ def _geocode(): dbt_seed = dbt_operator_factory( task_id="dbt_seed", - command="seed --full-refresh", + command="seed", ) dbt_create_udfs = dbt_operator_factory( diff --git a/pipeline/dbt/dbt_project.yml b/pipeline/dbt/dbt_project.yml index 39c4a75f..c90ff5b0 100644 --- a/pipeline/dbt/dbt_project.yml +++ b/pipeline/dbt/dbt_project.yml @@ -28,18 +28,27 @@ models: +materialized: table marts: - api: + +schema: marts + +contract: + enforced: true + + inclusion: +materialized: table - + opendata: +schema: opendata +materialized: view + +contract: + enforced: false seeds: data_inclusion: schema: +schema: schema + +full_refresh: true +column_types: value: text label: text - description: text \ No newline at end of file + description: text + +post-hook: + - "ALTER TABLE {{ this }} ADD UNIQUE (value)" diff --git a/pipeline/dbt/macros/marts_inclusion__unnest_jsonb_list_to_table.sql b/pipeline/dbt/macros/marts_inclusion__unnest_jsonb_list_to_table.sql new file mode 100644 index 00000000..a977d5ee --- /dev/null +++ b/pipeline/dbt/macros/marts_inclusion__unnest_jsonb_list_to_table.sql @@ -0,0 +1,18 @@ +{% macro unnest_jsonb_list_to_table(resource_type, nested_column) %} + +WITH {{ resource_type }}s AS ( + SELECT * FROM {{ ref('int__union_{}s__enhanced'.format(resource_type) ) }} +), + +final AS ( + SELECT + _di_surrogate_id AS "{{ resource_type }}_surrogate_id", + value_ AS "value" + FROM + {{ resource_type }}s, + UNNEST({{ nested_column }}) AS value_ +) + +SELECT * FROM final + +{% endmacro %} diff --git a/pipeline/dbt/models/marts/api/_api_models.yml b/pipeline/dbt/models/marts/api/_api_models.yml deleted file mode 100644 index 2c9052da..00000000 --- a/pipeline/dbt/models/marts/api/_api_models.yml +++ /dev/null @@ -1,206 +0,0 @@ -version: 2 - -models: - - name: api_structure - description: '{{ doc("api_structures") }}' - config: - alias: structure - contract: - enforced: true - columns: - - name: _di_surrogate_id - data_type: text - constraints: - - type: primary_key - - name: _di_geocodage_code_insee - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_INSEE(_di_geocodage_code_insee))' - - name: _di_geocodage_score - data_type: float - - name: id - data_type: text - constraints: - - type: not_null - - name: siret - data_type: text - - name: rna - data_type: text - - name: nom - data_type: text - constraints: - - type: not_null - - name: commune - data_type: text - - name: code_postal - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_POSTAL(code_postal))' - - name: code_insee - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_INSEE(code_insee))' - - name: adresse - data_type: text - - name: complement_adresse - data_type: text - - name: longitude - data_type: float - - name: latitude - data_type: float - - name: typologie - data_type: text - - name: telephone - data_type: text - - name: courriel - data_type: text - - name: site_web - data_type: text - - name: presentation_resume - data_type: text - - name: presentation_detail - data_type: text - - name: source - data_type: text - constraints: - - type: not_null - - name: date_maj - data_type: date - - name: antenne - data_type: boolean - - name: lien_source - data_type: text - - name: horaires_ouverture - data_type: text - - name: accessibilite - data_type: text - - name: labels_nationaux - data_type: text[] - - name: labels_autres - data_type: text[] - - name: thematiques - data_type: text[] - - - - name: api_service - description: '{{ doc("api_services") }}' - config: - alias: service - contract: - enforced: true - columns: - - name: _di_surrogate_id - data_type: text - constraints: - - type: primary_key - - name: _di_structure_surrogate_id - constraints: - - type: not_null - # FIXME: uncomment after upgrading dbt - # - type: foreign_key - # expression: '{{ ref('api_structure') }} (_di_surrogate_id)' - data_type: text - - name: _di_geocodage_code_insee - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_INSEE(_di_geocodage_code_insee))' - - name: _di_geocodage_score - data_type: float - - name: id - data_type: text - constraints: - - type: not_null - - name: structure_id - data_type: text - constraints: - - type: not_null - - name: source - data_type: text - constraints: - - type: not_null - - name: nom - data_type: text - constraints: - - type: not_null - - name: presentation_resume - data_type: text - - name: presentation_detail - data_type: text - - name: types - data_type: text[] - - name: thematiques - data_type: text[] - - name: prise_rdv - data_type: text - - name: frais - data_type: text[] - - name: frais_autres - data_type: text - - name: profils - data_type: text[] - - name: pre_requis - data_type: text[] - - name: cumulable - data_type: boolean - - name: justificatifs - data_type: text[] - - name: formulaire_en_ligne - data_type: text - - name: commune - data_type: text - - name: code_postal - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_POSTAL(code_postal))' - - name: code_insee - data_type: text - constraints: - - type: check - expression: '(CHECK_CODE_INSEE(code_insee))' - - name: adresse - data_type: text - - name: complement_adresse - data_type: text - - name: longitude - data_type: float - - name: latitude - data_type: float - - name: recurrence - data_type: text - - name: date_creation - data_type: date - - name: date_suspension - data_type: date - - name: lien_source - data_type: text - - name: telephone - data_type: text - - name: courriel - data_type: text - - name: contact_public - data_type: boolean - - name: contact_nom_prenom - data_type: text - - name: date_maj - data_type: date - - name: modes_accueil - data_type: text[] - - name: modes_orientation_accompagnateur - data_type: text[] - - name: modes_orientation_accompagnateur_autres - data_type: text - - name: modes_orientation_beneficiaire - data_type: text[] - - name: modes_orientation_beneficiaire_autres - data_type: text - - name: zone_diffusion_type - data_type: text - - name: zone_diffusion_code - data_type: text - - name: zone_diffusion_nom - data_type: text \ No newline at end of file diff --git a/pipeline/dbt/models/marts/api/api.md b/pipeline/dbt/models/marts/api/api.md deleted file mode 100644 index 71d422f5..00000000 --- a/pipeline/dbt/models/marts/api/api.md +++ /dev/null @@ -1,15 +0,0 @@ -{% docs api_structures %} - -Final table containing validated structures with PII and used by the api. - -The columns (must) match sqlalchemy model used by the data.inclusion api. - -{% enddocs %} - -{% docs api_services %} - -Final table containing validated services with PII and used by the api. - -The columns (must) match sqlalchemy model used by the data.inclusion api. - -{% enddocs %} diff --git a/pipeline/dbt/models/marts/api/api_service.sql b/pipeline/dbt/models/marts/api/api_service.sql deleted file mode 100644 index f16b30fa..00000000 --- a/pipeline/dbt/models/marts/api/api_service.sql +++ /dev/null @@ -1,40 +0,0 @@ -{{ - config( - pre_hook=[ - "DROP INDEX IF EXISTS service_structure_surrogate_id_idx", - "DROP INDEX IF EXISTS service_source_idx", - "DROP INDEX IF EXISTS service_modes_accueil_idx", - "DROP INDEX IF EXISTS service_thematiques_idx", - "DROP INDEX IF EXISTS service_geography_idx", - ], - post_hook=[ - "ALTER TABLE {{ this }} ADD CONSTRAINT services_structure_surrogate_id_fk FOREIGN KEY (_di_structure_surrogate_id) REFERENCES {{ ref('api_structure') }} (_di_surrogate_id)", - "CREATE INDEX IF NOT EXISTS service_structure_surrogate_id_idx ON service(_di_structure_surrogate_id);", - "CREATE INDEX IF NOT EXISTS service_source_idx ON {{ this }} (source);", - "CREATE INDEX IF NOT EXISTS service_modes_accueil_idx ON {{ this }} USING GIN (modes_accueil)", - "CREATE INDEX IF NOT EXISTS service_thematiques_idx ON {{ this }} USING GIN (thematiques)", - "CREATE INDEX IF NOT EXISTS service_geography_idx ON {{ this }} USING GIST ((ST_MakePoint(longitude, latitude)::geography(geometry, 4326)))", - ] - ) -}} - -WITH services AS ( - SELECT * FROM {{ ref('int__union_services__enhanced') }} -), - -final AS ( - SELECT - {{ - dbt_utils.star( - relation_alias='services', - from=ref('int__union_services__enhanced'), - except=[ - '_di_adresse_surrogate_id', - 'adresse_id', - ] - ) - }} - FROM services -) - -SELECT * FROM final diff --git a/pipeline/dbt/models/marts/inclusion/_inclusion_models.yml b/pipeline/dbt/models/marts/inclusion/_inclusion_models.yml new file mode 100644 index 00000000..381baa39 --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/_inclusion_models.yml @@ -0,0 +1,401 @@ +version: 2 + +models: + - name: marts_inclusion__structures + config: + indexes: + - columns: ['source'] + columns: + - name: _di_surrogate_id + data_type: text + constraints: + - type: primary_key + - name: _di_geocodage_code_insee + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_INSEE(_di_geocodage_code_insee))' + - name: _di_geocodage_score + data_type: float + - name: id + data_type: text + constraints: + - type: not_null + - name: siret + data_type: text + - name: rna + data_type: text + - name: nom + data_type: text + constraints: + - type: not_null + - name: commune + data_type: text + - name: code_postal + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_POSTAL(code_postal))' + - name: code_insee + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_INSEE(code_insee))' + - name: adresse + data_type: text + - name: complement_adresse + data_type: text + - name: longitude + data_type: float + - name: latitude + data_type: float + - name: typologie + data_type: text + - name: telephone + data_type: text + - name: courriel + data_type: text + - name: site_web + data_type: text + - name: presentation_resume + data_type: text + - name: presentation_detail + data_type: text + - name: source + data_type: text + constraints: + - type: not_null + - name: date_maj + data_type: date + - name: antenne + data_type: boolean + - name: lien_source + data_type: text + - name: horaires_ouverture + data_type: text + - name: accessibilite + data_type: text + - name: labels_nationaux + data_type: text[] + - name: labels_autres + data_type: text[] + - name: thematiques + data_type: text[] + + - name: marts_inclusion__structures_labels_nationaux + config: + indexes: + - columns: ['value'] + columns: + - name: structure_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__structures (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.labels_nationaux (value)" + + - name: marts_inclusion__structures_thematiques + config: + indexes: + - columns: ['value'] + columns: + - name: structure_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__structures (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.thematiques (value)" + + - name: marts_inclusion__services + config: + indexes: + - columns: ['_di_structure_surrogate_id'] + - columns: ['source'] + - columns: ['modes_accueil'] + type: gin + - columns: ['thematiques'] + type: gin + - columns: ['CAST(ST_MakePoint(longitude, latitude) AS geography(geometry, 4326))'] + type: gist + columns: + - name: _di_surrogate_id + data_type: text + constraints: + - type: primary_key + - name: _di_structure_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__structures (_di_surrogate_id)" + - name: _di_geocodage_code_insee + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_INSEE(_di_geocodage_code_insee))' + - name: _di_geocodage_score + data_type: float + - name: id + data_type: text + constraints: + - type: not_null + - name: structure_id + data_type: text + constraints: + - type: not_null + - name: source + data_type: text + constraints: + - type: not_null + - name: nom + data_type: text + constraints: + - type: not_null + - name: presentation_resume + data_type: text + - name: presentation_detail + data_type: text + - name: types + data_type: text[] + - name: thematiques + data_type: text[] + - name: prise_rdv + data_type: text + - name: frais + data_type: text[] + - name: frais_autres + data_type: text + - name: profils + data_type: text[] + - name: pre_requis + data_type: text[] + - name: cumulable + data_type: boolean + - name: justificatifs + data_type: text[] + - name: formulaire_en_ligne + data_type: text + - name: commune + data_type: text + - name: code_postal + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_POSTAL(code_postal))' + - name: code_insee + data_type: text + constraints: + - type: check + expression: '(CHECK_CODE_INSEE(code_insee))' + - name: adresse + data_type: text + - name: complement_adresse + data_type: text + - name: longitude + data_type: float + - name: latitude + data_type: float + - name: recurrence + data_type: text + - name: date_creation + data_type: date + - name: date_suspension + data_type: date + - name: lien_source + data_type: text + - name: telephone + data_type: text + - name: courriel + data_type: text + - name: contact_public + data_type: boolean + - name: contact_nom_prenom + data_type: text + - name: date_maj + data_type: date + - name: modes_accueil + data_type: text[] + - name: modes_orientation_accompagnateur + data_type: text[] + - name: modes_orientation_accompagnateur_autres + data_type: text + - name: modes_orientation_beneficiaire + data_type: text[] + - name: modes_orientation_beneficiaire_autres + data_type: text + - name: zone_diffusion_type + data_type: text + - name: zone_diffusion_code + data_type: text + - name: zone_diffusion_nom + data_type: text + + - name: marts_inclusion__services_frais + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.frais (value)" + + - name: marts_inclusion__services_justificatifs + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + + - name: marts_inclusion__services_modes_accueil + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.modes_accueil (value)" + + - name: marts_inclusion__services_modes_orientation_accompagnateur + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.modes_orientation_accompagnateur (value)" + + - name: marts_inclusion__services_modes_orientation_beneficiaire + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.modes_orientation_beneficiaire (value)" + + - name: marts_inclusion__services_profils + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.profils (value)" + + - name: marts_inclusion__services_pre_requis + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + + - name: marts_inclusion__services_thematiques + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.thematiques (value)" + + - name: marts_inclusion__services_types + config: + indexes: + - columns: ['value'] + columns: + - name: service_surrogate_id + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_marts.marts_inclusion__services (_di_surrogate_id)" + - name: value + data_type: text + constraints: + - type: not_null + - type: foreign_key + expression: "public_schema.typologies_de_services (value)" diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services.sql new file mode 100644 index 00000000..673f7ef1 --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services.sql @@ -0,0 +1,20 @@ +WITH services AS ( + SELECT * FROM {{ ref('int__union_services__enhanced') }} +), + +final AS ( + SELECT + {{ + dbt_utils.star( + relation_alias='services', + from=ref('int__union_services__enhanced'), + except=[ + '_di_adresse_surrogate_id', + 'adresse_id', + ] + ) + }} + FROM services +) + +SELECT * FROM final diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_frais.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_frais.sql new file mode 100644 index 00000000..face01ed --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_frais.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'frais') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_justificatifs.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_justificatifs.sql new file mode 100644 index 00000000..90c43e7a --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_justificatifs.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'justificatifs') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_accueil.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_accueil.sql new file mode 100644 index 00000000..cf1f0740 --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_accueil.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'modes_accueil') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_accompagnateur.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_accompagnateur.sql new file mode 100644 index 00000000..5b8f3221 --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_accompagnateur.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'modes_orientation_accompagnateur') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_beneficiaire.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_beneficiaire.sql new file mode 100644 index 00000000..b0f2dbbb --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_modes_orientation_beneficiaire.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'modes_orientation_beneficiaire') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_pre_requis.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_pre_requis.sql new file mode 100644 index 00000000..bad3790e --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_pre_requis.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'pre_requis') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_profils.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_profils.sql new file mode 100644 index 00000000..8ac9d78d --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_profils.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'profils') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_thematiques.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_thematiques.sql new file mode 100644 index 00000000..f49d85fb --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_thematiques.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'thematiques') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_types.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_types.sql new file mode 100644 index 00000000..8f9f73ab --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__services_types.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('service', 'types') }} diff --git a/pipeline/dbt/models/marts/api/api_structure.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures.sql similarity index 70% rename from pipeline/dbt/models/marts/api/api_structure.sql rename to pipeline/dbt/models/marts/inclusion/marts_inclusion__structures.sql index c8ca7abb..de75a35b 100644 --- a/pipeline/dbt/models/marts/api/api_structure.sql +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures.sql @@ -1,14 +1,3 @@ -{{ - config( - pre_hook=[ - "DROP INDEX IF EXISTS structure_source_idx", - ], - post_hook=[ - "CREATE INDEX IF NOT EXISTS structure_source_idx ON {{ this }} (source);", - ] - ) -}} - WITH structures AS ( SELECT * FROM {{ ref('int__union_structures__enhanced') }} ), diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_labels_nationaux.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_labels_nationaux.sql new file mode 100644 index 00000000..4e3798d8 --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_labels_nationaux.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('structure', 'labels_nationaux') }} diff --git a/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_thematiques.sql b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_thematiques.sql new file mode 100644 index 00000000..8bfa051c --- /dev/null +++ b/pipeline/dbt/models/marts/inclusion/marts_inclusion__structures_thematiques.sql @@ -0,0 +1 @@ +{{ unnest_jsonb_list_to_table('structure', 'thematiques') }}