-
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.
dbt: br_cgu_servidores_executivo_federal (#288)
* dbt: br_cgu_servidores_executivo_federal * rename tables * rename to staging * fix col values * fix col nivel_funcao * increase month
- Loading branch information
Showing
9 changed files
with
1,085 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -103,6 +103,9 @@ models: | |
+post-hook: | ||
- 'REVOKE `roles/bigquery.dataViewer` ON TABLE {{ this }} FROM "specialGroup:allUsers"' | ||
- 'GRANT `roles/bigquery.dataViewer` ON TABLE {{ this }} TO "group:[email protected]"' | ||
br_cgu_servidores_executivo_federal: | ||
+materialized: table | ||
+schema: br_cgu_servidores_executivo_federal | ||
br_cgu_pessoal_executivo_federal: | ||
+materialized: table | ||
+schema: br_cgu_pessoal_executivo_federal | ||
|
51 changes: 51 additions & 0 deletions
51
...br_cgu_servidores_executivo_federal/br_cgu_servidores_executivo_federal__afastamentos.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,51 @@ | ||
{{ | ||
config( | ||
schema = 'br_cgu_servidores_executivo_federal', | ||
alias = 'afastamentos', | ||
materialized='table', | ||
partition_by={ | ||
'field': 'ano', | ||
'data_type': 'int64', | ||
'range': { | ||
"start": 2015, | ||
"end": 2023, | ||
"interval": 1 | ||
} | ||
}, | ||
cluster_by=['ano', 'mes'], | ||
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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 7)', | ||
'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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 7)' | ||
] | ||
) | ||
}} | ||
|
||
select | ||
safe_cast(ano as int64) ano, | ||
safe_cast(mes as int64) mes, | ||
safe_cast(id_servidor as string) id_servidor, | ||
safe_cast(nome as string) nome, | ||
safe_cast(cpf as string) cpf, | ||
( | ||
case | ||
when data_inicio = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_inicio) | ||
end | ||
) as data_inicio, | ||
( | ||
case | ||
when data_final = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_final) | ||
end | ||
) as data_final, | ||
safe_cast(origem as string) origem, | ||
from | ||
`basedosdados-staging.br_cgu_servidores_executivo_federal_staging.afastamentos` as t |
97 changes: 97 additions & 0 deletions
97
...ervidores_executivo_federal/br_cgu_servidores_executivo_federal__cadastro_aposentados.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,97 @@ | ||
{{ | ||
config( | ||
schema = 'br_cgu_servidores_executivo_federal', | ||
alias = 'cadastro_aposentados', | ||
materialized='table', | ||
partition_by={ | ||
'field': 'ano', | ||
'data_type': 'int64', | ||
'range': { | ||
"start": 2020, | ||
"end": 2023, | ||
"interval": 1 | ||
} | ||
}, | ||
cluster_by=['ano', 'mes'], | ||
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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 7)', | ||
'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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 7)' | ||
] | ||
) | ||
}} | ||
|
||
select | ||
safe_cast(ano as int64) ano, | ||
safe_cast(mes as int64) mes, | ||
safe_cast(id_servidor as string) id_servidor, | ||
safe_cast(nome as string) nome, | ||
safe_cast(cpf as string) cpf, | ||
safe_cast(matricula as string) matricula, | ||
safe_cast(id_tipo_aposentadoria as string) id_tipo_aposentadoria, | ||
safe_cast(tipo_aposentadoria as string) tipo_aposentadoria, | ||
( | ||
case | ||
when data_aposentadoria = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_aposentadoria) | ||
end | ||
) as data_aposentadoria, | ||
safe_cast(descricao_cargo as string) descricao_cargo, | ||
safe_cast(id_uorg_lotacao as string) id_uorg_lotacao, | ||
safe_cast(uorg_lotacao as string) uorg_lotacao, | ||
safe_cast(id_org_lotacao as string) id_org_lotacao, | ||
safe_cast(org_lotacao as string) org_lotacao, | ||
safe_cast(id_orgsup_lotacao as string) id_orgsup_lotacao, | ||
safe_cast(orgsup_lotacao as string) orgsup_lotacao, | ||
safe_cast(id_tipo_vinculo as string) id_tipo_vinculo, | ||
safe_cast(tipo_vinculo as string) tipo_vinculo, | ||
safe_cast(situacao_vinculo as string) situacao_vinculo, | ||
safe_cast(regime_juridico as string) regime_juridico, | ||
safe_cast(jornada_trabalho as string) jornada_trabalho, | ||
( | ||
case | ||
when data_ingresso_cargo_funcao = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_ingresso_cargo_funcao) | ||
end | ||
) as data_ingresso_cargo_funcao, | ||
( | ||
case | ||
when data_nomeacao_cargo_funcao = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_nomeacao_cargo_funcao) | ||
end | ||
) as data_nomeacao_cargo_funcao, | ||
( | ||
case | ||
when data_ingresso_orgao = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_ingresso_orgao) | ||
end | ||
) as data_ingresso_orgao, | ||
safe_cast( | ||
documento_ingresso_servico_publico as string | ||
) documento_ingresso_servico_publico, | ||
( | ||
case | ||
when data_diploma_ingresso_servico_publico = "Não informada" | ||
then null | ||
else parse_date('%d/%m/%Y', data_diploma_ingresso_servico_publico) | ||
end | ||
) as data_diploma_ingresso_servico_publico, | ||
|
||
safe_cast(diploma_ingresso_cargo_funcao as string) diploma_ingresso_cargo_funcao, | ||
safe_cast(diploma_ingresso_orgao as string) diploma_ingresso_orgao, | ||
safe_cast( | ||
diploma_ingresso_servico_publico as string | ||
) diploma_ingresso_servico_publico, | ||
safe_cast(origem as string) origem, | ||
from | ||
`basedosdados-staging.br_cgu_servidores_executivo_federal_staging.cadastro_aposentados` | ||
as t |
110 changes: 110 additions & 0 deletions
110
...rvidores_executivo_federal/br_cgu_servidores_executivo_federal__cadastro_pensionistas.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,110 @@ | ||
{{ | ||
config( | ||
schema = 'br_cgu_servidores_executivo_federal', | ||
alias = 'cadastro_pensionistas', | ||
materialized='table', | ||
partition_by={ | ||
'field': 'ano', | ||
'data_type': 'int64', | ||
'range': { | ||
"start": 2020, | ||
"end": 2023, | ||
"interval": 1 | ||
} | ||
}, | ||
cluster_by=['ano', 'mes'], | ||
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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 7)', | ||
'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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 7)' | ||
] | ||
) | ||
}} | ||
|
||
select | ||
safe_cast(ano as int64) ano, | ||
safe_cast(mes as int64) mes, | ||
safe_cast(id_servidor as string) id_servidor, | ||
safe_cast(nome as string) nome, | ||
safe_cast(cpf as string) cpf, | ||
safe_cast(matricula as string) matricula, | ||
safe_cast(cpf_representante_legal as string) cpf_representante_legal, | ||
safe_cast(nome_representante_legal as string) nome_representante_legal, | ||
safe_cast(cpf_instituidor_pensao as string) cpf_instituidor_pensao, | ||
safe_cast(nome_instituidor_pensao as string) nome_instituidor_pensao, | ||
safe_cast(id_tipo_pensao as string) id_tipo_pensao, | ||
safe_cast(tipo_pensao as string) tipo_pensao, | ||
safe_cast(data_inicio_pensao as date) data_inicio_pensao, | ||
safe_cast( | ||
descricao_cargo_instituidor_pensao as string | ||
) descricao_cargo_instituidor_pensao, | ||
safe_cast( | ||
id_uorg_lotacao_instituidor_pensao as string | ||
) id_uorg_lotacao_instituidor_pensao, | ||
safe_cast( | ||
uorg_lotacao_instituidor_pensao as string | ||
) uorg_lotacao_instituidor_pensao, | ||
safe_cast( | ||
id_org_lotacao_instituidor_pensao as string | ||
) id_org_lotacao_instituidor_pensao, | ||
safe_cast(org_lotacao_instituidor_pensao as string) org_lotacao_instituidor_pensao, | ||
safe_cast( | ||
id_orgsup_lotacao_instituidor_pensao as string | ||
) id_orgsup_lotacao_instituidor_pensao, | ||
safe_cast( | ||
orgsup_lotacao_instituidor_pensao as string | ||
) orgsup_lotacao_instituidor_pensao, | ||
safe_cast(id_tipo_vinculo as string) id_tipo_vinculo, | ||
safe_cast(tipo_vinculo as string) tipo_vinculo, | ||
safe_cast(situacao_vinculo as string) situacao_vinculo, | ||
safe_cast( | ||
regime_juridico_instituidor_pensao as string | ||
) regime_juridico_instituidor_pensao, | ||
safe_cast( | ||
jornada_trabalho_instituidor_pensao as string | ||
) jornada_trabalho_instituidor_pensao, | ||
( | ||
case | ||
when data_ingresso_cargo_funcao_instituidor_pensao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_ingresso_cargo_funcao_instituidor_pensao) | ||
end | ||
) as data_ingresso_cargo_funcao_instituidor_pensao, | ||
( | ||
case | ||
when data_nomeacao_cargo_funcao_instituidor_pensao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_nomeacao_cargo_funcao_instituidor_pensao) | ||
end | ||
) as data_nomeacao_cargo_funcao_instituidor_pensao, | ||
( | ||
case | ||
when data_ingresso_orgao_instituidor_pensao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_ingresso_orgao_instituidor_pensao) | ||
end | ||
) as data_ingresso_orgao_instituidor_pensao, | ||
( | ||
case | ||
when data_diploma_ingresso_servico_publico_instituidor_pensao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_diploma_ingresso_servico_publico_instituidor_pensao) | ||
end | ||
) as data_diploma_ingresso_servico_publico_instituidor_pensao, | ||
safe_cast( | ||
documento_ingresso_servico_publico_instituidor_pensao as string | ||
) documento_ingresso_servico_publico_instituidor_pensao, | ||
safe_cast( | ||
diploma_ingresso_cargo_funcao_instituidor_pensao as string | ||
) diploma_ingresso_cargo_funcao_instituidor_pensao, | ||
safe_cast( | ||
diploma_ingresso_orgao_instituidor_pensao as string | ||
) diploma_ingresso_orgao_instituidor_pensao, | ||
safe_cast( | ||
diploma_ingresso_servicopublico_instituidor_pensao as string | ||
) diploma_ingresso_servicopublico_instituidor_pensao, | ||
safe_cast(origem as string) origem, | ||
from | ||
`basedosdados-staging.br_cgu_servidores_executivo_federal_staging.cadastro_pensionistas` | ||
as t |
91 changes: 91 additions & 0 deletions
91
...utivo_federal/br_cgu_servidores_executivo_federal__cadastro_reserva_reforma_militares.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,91 @@ | ||
{{ | ||
config( | ||
schema = 'br_cgu_servidores_executivo_federal', | ||
alias = 'cadastro_reserva_reforma_militares', | ||
materialized='table', | ||
partition_by={ | ||
'field': 'ano', | ||
'data_type': 'int64', | ||
'range': { | ||
"start": 2020, | ||
"end": 2023, | ||
"interval": 1 | ||
} | ||
}, | ||
cluster_by=['ano', 'mes'], | ||
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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 7)', | ||
'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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 7)' | ||
] | ||
) | ||
}} | ||
|
||
select | ||
safe_cast(ano as int64) ano, | ||
safe_cast(mes as int64) mes, | ||
safe_cast(id_servidor as string) id_servidor, | ||
safe_cast(nome as string) nome, | ||
safe_cast(cpf as string) cpf, | ||
safe_cast(matricula as string) matricula, | ||
safe_cast(id_tipo_aposentadoria as string) id_tipo_aposentadoria, | ||
safe_cast(tipo_aposentadoria as string) tipo_aposentadoria, | ||
( | ||
case | ||
when data_aposentadoria = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_aposentadoria) | ||
end | ||
) as data_aposentadoria, | ||
safe_cast(descricao_cargo as string) descricao_cargo, | ||
safe_cast(id_uorg_lotacao as string) id_uorg_lotacao, | ||
safe_cast(uorg_lotacao as string) uorg_lotacao, | ||
safe_cast(id_org_lotacao as string) id_org_lotacao, | ||
safe_cast(org_lotacao as string) org_lotacao, | ||
safe_cast(id_orgsup_lotacao as string) id_orgsup_lotacao, | ||
safe_cast(orgsup_lotacao as string) orgsup_lotacao, | ||
safe_cast(id_tipo_vinculo as string) id_tipo_vinculo, | ||
safe_cast(tipo_vinculo as string) tipo_vinculo, | ||
safe_cast(situacao_vinculo as string) situacao_vinculo, | ||
safe_cast(regime_juridico as string) regime_juridico, | ||
safe_cast(jornada_trabalho as string) jornada_trabalho, | ||
( | ||
case | ||
when data_ingresso_cargo_funcao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_ingresso_cargo_funcao) | ||
end | ||
) as data_ingresso_cargo_funcao, | ||
( | ||
case | ||
when data_nomeacao_cargo_funcao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_nomeacao_cargo_funcao) | ||
end | ||
) as data_nomeacao_cargo_funcao, | ||
( | ||
case | ||
when data_ingresso_orgao = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_ingresso_orgao) | ||
end | ||
) as data_ingresso_orgao, | ||
( | ||
case | ||
when data_diploma_ingresso_servico_publico = "Não informada" then null | ||
else parse_date('%d/%m/%Y', data_diploma_ingresso_servico_publico) | ||
end | ||
) as data_diploma_ingresso_servico_publico, | ||
safe_cast( | ||
documento_ingresso_servico_publico as string | ||
) documento_ingresso_servico_publico, | ||
safe_cast(diploma_ingresso_cargo_funcao as string) diploma_ingresso_cargo_funcao, | ||
safe_cast(diploma_ingresso_orgao as string) diploma_ingresso_orgao, | ||
safe_cast( | ||
diploma_ingresso_servico_publico as string | ||
) diploma_ingresso_servico_publico, | ||
from | ||
`basedosdados-staging.br_cgu_servidores_executivo_federal_staging.cadastro_reserva_reforma_militares` | ||
as t | ||
|
Oops, something went wrong.