Skip to content
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

[Refactor] br_me_caged #840

Merged
merged 6 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{{
config(
schema="br_me_caged",
materialized="table",
materialized="incremental",
alias="microdados_movimentacao",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2020, "end": 2024, "interval": 1},
"range": {"start": 2020, "end": 2025, "interval": 1},
},
cluster_by=["mes", "sigla_uf"],
labels={"project_id": "basedosdados", "tema": "economia"},
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
Expand Down Expand Up @@ -50,3 +52,9 @@ from `basedosdados-staging.br_me_caged_staging.microdados_movimentacao` a
left join
`basedosdados.br_bd_diretorios_brasil.municipio` b
on a.id_municipio = b.id_municipio_6

{% if is_incremental() %}
where
date(cast(ano as int64), cast(mes as int64), 1)
> (select max(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
config(
schema="br_me_caged",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2020, "end": 2024, "interval": 1},
},
cluster_by=["mes", "sigla_uf"],
alias="microdados_movimentacao_excluida",
labels={"project_id": "basedosdados", "tema": "economia"},
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{
config(
schema="br_me_caged",
materialized="table",
materialized="incremental",
alias="microdados_movimentacao_fora_prazo",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2020, "end": 2024, "interval": 1},
"range": {"start": 2020, "end": 2025, "interval": 1},
},
cluster_by=["mes", "sigla_uf"],
labels={"project_id": "basedosdados", "tema": "economia"},
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
)
Expand Down Expand Up @@ -50,3 +50,8 @@ from `basedosdados-staging.br_me_caged_staging.microdados_movimentacao_fora_praz
left join
`basedosdados.br_bd_diretorios_brasil.municipio` b
on a.id_municipio = b.id_municipio_6
{% if is_incremental() %}
where
date(cast(ano as int64), cast(mes as int64), 1)
> (select max(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
{% endif %}
2 changes: 1 addition & 1 deletion models/br_me_caged/schema.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 2
models:
- name: microdados_movimentacao
- name: br_me_caged__microdados_movimentacao
description: Contém dados de movimentações declaradas dentro do prazo com competência
de declaração.
tests:
Expand Down