-
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.
Merge branch 'main' into staging/br_ibge_censo_2022
- Loading branch information
Showing
1 changed file
with
3 additions
and
28 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,26 +1,10 @@ | ||
{{ | ||
config( | ||
alias = 'dia', | ||
schema='br_cvm_oferta_publica_distribuicao', | ||
materialized='incremental', | ||
partition_by = { | ||
"field": "data_abertura_processo", | ||
"data_type": "date", | ||
"granularity": "day" | ||
}, | ||
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(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(data_abertura_processo), 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(data_abertura_processo), MONTH) <= 6)'] | ||
) | ||
schema='br_cvm_oferta_publica_distribuicao') | ||
}} | ||
|
||
WITH tabela as(SELECT | ||
SELECT | ||
SAFE_CAST(numero_processo AS STRING) numero_processo, | ||
SAFE_CAST(numero_registro_oferta AS STRING) numero_registro_oferta, | ||
SAFE_CAST(tipo_oferta AS STRING) tipo_oferta, | ||
|
@@ -65,13 +49,4 @@ SAFE_CAST(tipo_societario_emissor AS STRING) tipo_societario_emissor, | |
SAFE_CAST(tipo_fundo_investimento AS STRING) tipo_fundo_investimento, | ||
SAFE_CAST(ultimo_comunicado AS STRING) ultimo_comunicado, | ||
SAFE_CAST(data_comunicado AS DATE) data_comunicado | ||
FROM basedosdados-staging.br_cvm_oferta_publica_distribuicao_staging.dia AS t) | ||
SELECT * | ||
FROM tabela | ||
{% if is_incremental() %} | ||
|
||
-- this filter will only be applied on an incremental run | ||
-- (uses > to include records whose timestamp occurred since the last run of this model) | ||
where data_abertura_processo > (select max(data_abertura_processo) from {{ this }}) | ||
|
||
{% endif %} | ||
FROM basedosdados-staging.br_cvm_oferta_publica_distribuicao_staging.dia AS t |