-
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 branch 'staging/mundo_transfermarkt_competicoes.copa_brasil' of h…
…ttps://github.com/basedosdados/queries-basedosdados into staging/mundo_transfermarkt_competicoes.copa_brasil
- Loading branch information
Showing
15 changed files
with
730 additions
and
122 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,18 @@ | ||
{{ | ||
config( | ||
schema = "world_wb_mides", | ||
materialized = "table", | ||
cluster_by = ["sigla_uf"], | ||
labels = {"project_id": "basedosdados", "tema": "economia"} | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(ano AS STRING) ano, | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(orgao AS STRING) orgao, | ||
SAFE_CAST(nome_orgao AS STRING) nome_orgao, | ||
SAFE_CAST(id_unidade_gestora AS STRING) id_unidade_gestora, | ||
SAFE_CAST(nome_unidade_gestora AS STRING) nome_unidade_gestora, | ||
SAFE_CAST(esfera AS STRING) esfera | ||
FROM basedosdados-staging.world_wb_mides_staging.orgao_unidade_gestora AS t |
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
Oops, something went wrong.