Skip to content

Commit

Permalink
Merge pull request #828 from basedosdados/staging/partitions_cnpj
Browse files Browse the repository at this point in the history
[BugFix] br_me_cnpj
  • Loading branch information
folhesgabriel authored Nov 19, 2024
2 parents ac5afc7 + ee5ff8f commit 13fdeb0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions models/br_me_cnpj/br_me_cnpj__empresas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"field": "data",
"data_type": "date",
},
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
incremental_strategy="insert_overwrite",
pre_hook=[
"DROP ALL ROW ACCESS POLICIES ON {{ this }}",
"DELETE FROM {{ this }} WHERE data > '2024-03-15'",
],
)
}}
with
Expand All @@ -27,4 +31,4 @@ with
)
select *
from cnpj_empresas
{% if is_incremental() %} where data > (select max(data) from {{ this }}) {% endif %}
{% if is_incremental() %} where data = '2024-11-15' {% endif %}
8 changes: 6 additions & 2 deletions models/br_me_cnpj/br_me_cnpj__estabelecimentos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"data_type": "date",
},
cluster_by="sigla_uf",
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
incremental_strategy="insert_overwrite",
pre_hook=[
"DROP ALL ROW ACCESS POLICIES ON {{ this }}",
"DELETE FROM {{ this }} WHERE data > '2024-03-15'",
],
)
}}
with
Expand Down Expand Up @@ -59,4 +63,4 @@ with
)
select *
from cnpj_estabelecimentos
{% if is_incremental() %} where data > (select max(data) from {{ this }}) {% endif %}
{% if is_incremental() %} where data = '2024-11-15' {% endif %}
8 changes: 6 additions & 2 deletions models/br_me_cnpj/br_me_cnpj__socios.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"field": "data",
"data_type": "date",
},
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
incremental_strategy="insert_overwrite",
pre_hook=[
"DROP ALL ROW ACCESS POLICIES ON {{ this }}",
"DELETE FROM {{ this }} WHERE data > '2024-03-15'",
],
)
}}
with
Expand All @@ -32,4 +36,4 @@ with
)
select *
from cnpj_socios
{% if is_incremental() %} where data > (select max(data) from {{ this }}) {% endif %}
{% if is_incremental() %} where data = '2024-11-15' {% endif %}

0 comments on commit 13fdeb0

Please sign in to comment.