Skip to content

Commit

Permalink
Merge branch 'main' into staging/br_ibge_censo_2022
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfg authored Jan 3, 2024
2 parents f0e7b8c + efdd10b commit 07715e7
Showing 1 changed file with 3 additions and 28 deletions.
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,
Expand Down Expand Up @@ -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

0 comments on commit 07715e7

Please sign in to comment.