-
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 pull request #271 from basedosdados/br_cvm
[dbt] `br_cvm`
- Loading branch information
Showing
7 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
models/br_cvm_administradores_carteira/br_cvm_administradores_carteira__pessoa_fisica.sql
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{ | ||
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:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") | ||
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(data_registro), MONTH) <= 6)'] | ||
) | ||
}} | ||
WITH tabela as( 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) | ||
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_registro > (select max(data_registro) from {{ this }}) | ||
|
||
{% endif %} |
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
9 changes: 8 additions & 1 deletion
9
..._administradores_carteira/responsavel.sql → ...administradores_carteira__responsavel.sql
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,5 +1,12 @@ | ||
{{ | ||
config( | ||
alias = 'responsavel', | ||
schema='br_cvm_administradores_carteira', | ||
materialized='table', | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(cnpj AS STRING) cnpj, | ||
SAFE_CAST(nome AS STRING) nome, | ||
SAFE_CAST(tipo AS STRING) tipo | ||
FROM basedosdados-staging.br_cvm_administradores_carteira_staging.responsavel AS t | ||
FROM basedosdados-staging.br_cvm_administradores_carteira_staging.responsavel AS t |
This file was deleted.
Oops, something went wrong.
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
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
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