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

[feat] removing _atualizado tables #264

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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,9 +1,18 @@
{{ config(alias='densidade_brasil', schema='br_anatel_banda_larga_fixa') }}
{{ config(alias='densidade_brasil', schema='br_anatel_banda_larga_fixa',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR
DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)'] ) }}

SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(densidade AS FLOAT64) densidade
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.densidade_brasil AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{{ config(
alias='densidade_municipio',
schema='br_anatel_banda_larga_fixa')
schema='br_anatel_banda_larga_fixa',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR
DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)'] )
}}

SELECT
Expand All @@ -9,6 +20,4 @@ SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
SAFE_CAST(id_municipio AS STRING) id_municipio,
SAFE_CAST(densidade AS FLOAT64) densidade
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.densidade_municipio AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.densidade_municipio AS t

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{{ config(alias='densidade_uf', schema='br_anatel_banda_larga_fixa') }}
{{ config(alias='densidade_uf', schema='br_anatel_banda_larga_fixa',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR
DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)'] ) }}

SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
SAFE_CAST(densidade AS FLOAT64) densidade
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.densidade_uf AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
"interval": 1}
},
cluster_by = ["id_municipio", "mes"],
labels = {'project_id': 'basedosdados'})
labels = {'project_id': 'basedosdados'},
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR
DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)'] )
}}

SELECT
Expand All @@ -27,6 +38,4 @@ SAFE_CAST(transmissao AS STRING) transmissao,
SAFE_CAST(velocidade AS STRING) velocidade,
SAFE_CAST(produto AS STRING) produto,
SAFE_CAST(acessos AS INT64) acessos
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.microdados AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)
FROM basedosdados-staging.br_anatel_banda_larga_fixa_staging.microdados AS t

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{{ config(alias='densidade_brasil', schema='br_anatel_telefonia_movel') }}
{{ config(alias='densidade_brasil', schema='br_anatel_telefonia_movel',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),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 (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)'] ) }}

SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(densidade AS FLOAT64) densidade

FROM basedosdados-staging.br_anatel_telefonia_movel_staging.densidade_brasil AS t
WHERE DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{{ config(alias='densidade_municipio', schema='br_anatel_telefonia_movel') }}
{{ config(alias='densidade_municipio', schema='br_anatel_telefonia_movel',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),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 (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)']) }}

SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
REPLACE(CAST(id_municipio AS STRING), '.0', '') id_municipio,
SAFE_CAST(densidade AS FLOAT64) densidade

FROM basedosdados-staging.br_anatel_telefonia_movel_staging.densidade_municipio AS t
WHERE DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{{ config(alias='densidade_uf', schema='br_anatel_telefonia_movel') }}

{{ config(alias='densidade_uf', schema='br_anatel_telefonia_movel',
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),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 (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)']) }}

SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
SAFE_CAST(densidade AS FLOAT64) densidade

FROM basedosdados-staging.br_anatel_telefonia_movel_staging.densidade_uf AS t
WHERE DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
FROM basedosdados-staging.br_anatel_telefonia_movel_staging.densidade_uf AS t

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
"interval": 1}
},
cluster_by = ["id_municipio", "mes"],
labels = {'project_id': 'basedosdados'})
labels = {'project_id': 'basedosdados'},
post_hook = [
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter
ON {{this}}
GRANT TO ("allUsers")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),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 (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)'])
}}


Expand All @@ -30,6 +39,5 @@ SAFE_CAST(modalidade AS STRING) modalidade,
SAFE_CAST(pessoa AS STRING) pessoa,
SAFE_CAST(produto AS STRING) produto,
SAFE_CAST(acessos AS INT64) acessos

FROM basedosdados-staging.br_anatel_telefonia_movel_staging.microdados AS t
WHERE DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6

This file was deleted.

13 changes: 10 additions & 3 deletions models/br_me_comex_stat/municipio_exportacao.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
"interval": 1}
},
cluster_by = ["mes", "sigla_uf"],
labels = {'project_id': 'basedosdados', 'tema': 'economia'})
labels = {'project_id': 'basedosdados', 'tema': 'economia'},
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 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)'] )
}}
SELECT
SAFE_CAST(ano AS INT64) ano,
Expand All @@ -23,5 +32,3 @@ SAFE_CAST(id_municipio AS STRING) id_municipio,
SAFE_CAST(peso_liquido_kg AS INT64) peso_liquido_kg,
SAFE_CAST(valor_fob_dolar AS INT64) valor_fob_dolar
FROM basedosdados-staging.br_me_comex_stat_staging.municipio_exportacao AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)
Loading
Loading