Skip to content

Commit

Permalink
Merge branch 'main' into add-tests-transfermark
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfg authored Apr 10, 2024
2 parents 701efdb + 8681112 commit 021f04a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
cluster_by="sigla_uf",
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(sigla_uf as string) sigla_uf,
Expand Down
8 changes: 8 additions & 0 deletions models/br_inep_censo_escolar/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@

bq_storage_cols_order = [i["name"] for i in bq_cols["columns"]]

df["rede"].unique() # type: ignore

df["rede"] = df["rede"].replace( # type: ignore
{"1": "federal", "2": "estadual", "3": "municipal", "4": "privada"}
)

df["rede"].unique() # type: ignore

for keys, df_split in df.groupby(partitions):
ano, sigla_uf = keys # type: ignore
path = os.path.join(OUTPUT, f"ano={ano}", f"sigla_uf={sigla_uf}")
Expand Down
2 changes: 2 additions & 0 deletions models/br_inep_censo_escolar/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,8 @@ models:
- relationships:
to: ref('br_bd_diretorios_brasil__escola')
field: rede
- accepted_values:
values: [municipal, estadual, federal, privada]
- name: id_escola
description: Código da Escola
- name: id_turma
Expand Down
14 changes: 10 additions & 4 deletions models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"range": {"start": 2005, "end": 2024, "interval": 1},
},
cluster_by=["mes", "sigla_uf"],
pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}",
post_hook=[
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter ON {{this}} GRANT TO ("allUsers") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter ON {{this}} GRANT TO ("group:[email protected]", "group:[email protected]") FILTER USING (True)',
],
)
}}

Expand Down Expand Up @@ -227,8 +232,9 @@ from sia

{% 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 }})
or date(cast(ano as int64), cast(mes as int64), 1)
< (select min(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
date(cast(ano as int64), cast(mes as int64), 1) not in (
select distinct (date(cast(ano as int64), cast(mes as int64), 1))
from {{ this }}
)

{% endif %}

0 comments on commit 021f04a

Please sign in to comment.