Skip to content

Commit

Permalink
Merge pull request #810 from MTES-MCT/feat-non-incremental
Browse files Browse the repository at this point in the history
Rend la table OCS Ge x GPU non incrmeental
  • Loading branch information
alexisig authored Dec 23, 2024
2 parents e8c25b1 + 58b025c commit 07ce06e
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{
config(
materialized='incremental',
indexes=[
{'columns': ['departement'], 'type': 'btree'},
{'columns': ['year'], 'type': 'btree'},
Expand All @@ -10,23 +9,9 @@
{'columns': ['zonage_gpu_timestamp'], 'type': 'btree'},
{'columns': ['geom'], 'type': 'gist'}
],
pre_hook=[
"{{ delete_from_this_where_field_not_in('ocsge_loaded_date', 'occupation_du_sol', 'loaded_date') }}",
"{{ delete_from_this_where_field_not_in('zonage_checksum', 'zonage_urbanisme', 'checksum') }}",
]
)
}}

/*
Cette requête découpe les objets OCS GE d'occupation du sol par zonage d'urbanisme.
Dans le cas où un objet OCS GE est découpé par plusieurs zonages, il sera dupliqué, mais
la surface totale de l'objet sera conservée.
*/


with max_ocsge_loaded_date as (
SELECT max(ocsge_loaded_date) as ocsge_loaded_date FROM {{ this }}
), max_zonage_gpu_timestamp as (
Expand Down Expand Up @@ -58,19 +43,13 @@ with max_ocsge_loaded_date as (
ST_Intersects(zonage.geom, ocsge.geom)
AND
zonage.srid_source = ocsge.srid_source

{% if is_incremental() %}
where ocsge.loaded_date > (select ocsge_loaded_date from max_ocsge_loaded_date)
or zonage.gpu_timestamp > (select zonage_gpu_timestamp from max_zonage_gpu_timestamp)
{% endif %}
), occupation_du_sol_zonage_urbanisme_without_surface_with_duplicates_marked as (
SELECT
*,
row_number() over (partition by geom, year, departement) as rn
FROM
occupation_du_sol_zonage_urbanisme_without_surface
)

SELECT
*,
ST_Area(geom) as surface
Expand Down

0 comments on commit 07ce06e

Please sign in to comment.