Skip to content

Commit

Permalink
Merge pull request #380 from basedosdados/fix/br_cvm_oferta_publica_d…
Browse files Browse the repository at this point in the history
…istribuicao

fix: remove incremental from br_cvm_oferta_publica_distribuicao
  • Loading branch information
laura-l-amaral authored Jan 2, 2024
2 parents f4a38da + ebba045 commit 7aeb213
Showing 1 changed file with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,14 @@
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)']
)
})
}}

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 +54,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 7aeb213

Please sign in to comment.