Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dbt] br_cvm #271

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
folhesgabriel marked this conversation as resolved.
Show resolved Hide resolved
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
folhesgabriel marked this conversation as resolved.
Show resolved Hide resolved
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:bd-pro@basedosdados.org", "group:sudo@basedosdados.org")
FILTER USING (EXTRACT(YEAR from data_registro) = EXTRACT(YEAR from DATE("{{ run_started_at.strftime("%Y-%m-%d") }}")))' ]
folhesgabriel marked this conversation as resolved.
Show resolved Hide resolved
)
}}
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-staging.br_cvm_administradores_carteira_staging.pessoa_fisica AS t
folhesgabriel marked this conversation as resolved.
Show resolved Hide resolved
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:bd-pro@basedosdados.org", "group:sudo@basedosdados.org")
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',
folhesgabriel marked this conversation as resolved.
Show resolved Hide resolved
)
}}
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:bd-pro@basedosdados.org", "group:sudo@basedosdados.org")
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
Loading