-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclui modelos _atualizado, setta materialização incremental e permis…
…sionamento por linha
- Loading branch information
1 parent
715ff86
commit 00f328c
Showing
8 changed files
with
81 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
{{ config( | ||
alias = 'agencia', | ||
schema = 'br_bcb_agencia') | ||
}} | ||
{{ | ||
config( | ||
schema='br_bcb_agencia', | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 2007, | ||
"end": 2024, | ||
"interval": 1} | ||
}, | ||
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 (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)' | ||
] | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
|
@@ -23,4 +44,6 @@ SAFE_CAST(ddd AS STRING) ddd, | |
SAFE_CAST(fone AS STRING) fone, | ||
SAFE_CAST(id_instalacao AS STRING) id_instalacao | ||
FROM basedosdados-staging.br_bcb_agencia_staging.agencia AS t | ||
WHERE DATE(CAST(ano AS INT64),CAST(mes AS INT64),1)<= DATE(2023,2,1) | ||
{% 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 %} |
30 changes: 0 additions & 30 deletions
30
models/br_bcb_agencia/br_bcb_agencia__agencia_atualizado.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
config( | ||
alias = 'agencia', | ||
schema='br_bcb_estban', | ||
materialized='table', | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
|
@@ -12,7 +12,19 @@ | |
"interval": 1} | ||
}, | ||
cluster_by = ["mes", "sigla_uf"], | ||
labels = {'project_id': 'basedosdados', 'tema': 'economia'}) | ||
labels = {'project_id': 'basedosdados-dev', 'tema': 'economia'}, | ||
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 (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)' | ||
] | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
|
@@ -25,5 +37,7 @@ SELECT | |
SAFE_CAST(id_verbete AS STRING) id_verbete, | ||
SAFE_CAST(valor AS FLOAT64) valor | ||
FROM basedosdados-staging.br_bcb_estban_staging.agencia AS t | ||
WHERE DATE(CAST(ano AS INT64),CAST(mes AS INT64),1)<= DATE(2023,3,1) | ||
{% 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 %} | ||
|
31 changes: 0 additions & 31 deletions
31
models/br_bcb_estban/br_bcb_estban__agencia_atualizado.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
config( | ||
alias = 'municipio', | ||
schema='br_bcb_estban', | ||
materialized='table', | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
|
@@ -12,7 +12,18 @@ | |
"interval": 1} | ||
}, | ||
cluster_by = ["mes", "sigla_uf"], | ||
labels = {'project_id': 'basedosdados', 'tema': 'economia'}) | ||
labels = {'project_id': 'basedosdados-dev', 'tema': 'economia'}, | ||
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 (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)' | ||
]) | ||
}} | ||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
|
@@ -26,4 +37,6 @@ SELECT | |
SAFE_CAST(id_verbete AS STRING) id_verbete, | ||
SAFE_CAST(valor AS FLOAT64) valor | ||
FROM basedosdados-staging.br_bcb_estban_staging.municipio AS t | ||
WHERE DATE(CAST(ano AS INT64),CAST(mes AS INT64),1)<= DATE(2023,3,1) | ||
{% 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 %} |
30 changes: 0 additions & 30 deletions
30
models/br_bcb_estban/br_bcb_estban__municipio_atualizado.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters