Skip to content

Commit

Permalink
Merge pull request #299 from basedosdados/br_cvm
Browse files Browse the repository at this point in the history
[dbt] `br_cvm`
  • Loading branch information
folhesgabriel authored Sep 20, 2023
2 parents 40e512a + a4d27ba commit aeb2326
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{
config(
alias = 'pessoa_fisica',
schema='br_cvm_administradores_carteira',
materialized='incremental',
partition_by = {
"field": "data_registro",
"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_registro), MONTH) > 6)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (EXTRACT(YEAR from data_registro) = EXTRACT(YEAR from DATE("{{ run_started_at.strftime("%Y-%m-%d") }}")))' ]
)
}}
SELECT
SAFE_CAST(nome AS STRING) nome,
SAFE_CAST(data_registro AS DATE) data_registro,
SAFE_CAST(data_cancelamento AS DATE) data_cancelamento,
SAFE_CAST(motivo_cancelamento AS STRING) motivo_cancelamento,
SAFE_CAST(situacao AS STRING) situacao,
SAFE_CAST(data_inicio_situacao AS DATE) data_inicio_situacao,
SAFE_CAST(categoria_registro AS STRING) categoria_registro
FROM basedosdados-dev.br_cvm_administradores_carteira_staging.pessoa_fisica AS t
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
{{
config(
alias = 'pessoa_juridica',
schema='br_cvm_administradores_carteira',
materialized='incremental',
partition_by = {
"field": "data_registro",
"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_registro), MONTH) > 6)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (EXTRACT(YEAR from data_registro) = EXTRACT(YEAR from DATE("{{ run_started_at.strftime("%Y-%m-%d") }}")))' ]
)
}}

SELECT
SAFE_CAST(cnpj AS STRING) cnpj,
SAFE_CAST(denominacao_social AS STRING) denominacao_social,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{{
config(
alias = 'responsavel',
schema='br_cvm_administradores_carteira',
materialized='incremental',
)
}}
SELECT
SAFE_CAST(cnpj AS STRING) cnpj,
SAFE_CAST(nome AS STRING) nome,
Expand Down
9 changes: 0 additions & 9 deletions models/br_cvm_administradores_carteira/pessoa_fisica.sql

This file was deleted.

12 changes: 6 additions & 6 deletions models/br_cvm_administradores_carteira/schema.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2

models:
- name: pessoa_fisica
description: "dbt model for pessoa_fisica"
- name: br_cvm_administradores_carteira__pessoa_fisica
description: Dados Cadastrais de Administradores de Carteira da CVM (Pessoa Física)
columns:
- name: nome
description: Nome
Expand All @@ -18,8 +18,8 @@ models:
description: Data de início da situação
- name: categoria_registro
description: Categoria de registro
- name: pessoa_juridica
description: "dbt model for pessoa_juridica"
- name: br_cvm_administradores_carteira__pessoa_juridica
description: Dados Cadastrais de Administradores de Carteira da CVM (Pessoa Jurídica)
columns:
- name: cnpj
description: Cadastro Nacional de Pessoas Jurídicas (CNPJ)
Expand Down Expand Up @@ -69,8 +69,8 @@ models:
description: Email
- name: website
description: Website
- name: responsavel
description: "dbt model for responsavel"
- name: br_cvm_administradores_carteira__responsavel
description: Dados Cadastrais de Administradores de Carteira da CVM.
columns:
- name: cnpj
description: Cadastro Nacional de Pessoas Jurídicas (CNPJ)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
{{
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 (EXTRACT(YEAR from data_abertura_processo) = EXTRACT(YEAR from DATE("{{ run_started_at.strftime("%Y-%m-%d") }}")))' ]
)
}}

SELECT
SAFE_CAST(numero_processo AS STRING) numero_processo,
SAFE_CAST(numero_registro_oferta AS STRING) numero_registro_oferta,
Expand Down
4 changes: 2 additions & 2 deletions models/br_cvm_oferta_publica_distribuicao/schema.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2

models:
- name: dia
description: "dbt model for table dia"
- name: br_cvm_oferta_publica_distribuicao__dia
description: Ofertas de distribuição (ações, fundos, debêntures, CRI, etc) registradas ou dispensadas de registro.
columns:
- name: numero_processo
description: Número do processo administrativo
Expand Down

0 comments on commit aeb2326

Please sign in to comment.