Skip to content

Commit

Permalink
Merge pull request #631 from basedosdados/cgu_licitacao_contrato
Browse files Browse the repository at this point in the history
[dbt] br_cgu_licitacao_contrato
  • Loading branch information
tricktx authored Nov 26, 2024
2 parents ff6bafa + 2f876d9 commit d1848ec
Show file tree
Hide file tree
Showing 9 changed files with 540 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ models:
br_cgu_emenda_parlamentar:
+materialized: table
+schema: br_cgu_emendas_parlamentares
br_cgu_licitacao_contrato:
+materialized: table
+schema: br_cgu_licitacao_contrato
br_cgu_pessoal_executivo_federal:
+materialized: table
+schema: br_cgu_pessoal_executivo_federal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{
config(
alias="contrato_compra",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(numero_do_contrato as string) id_contrato,
safe_cast(objeto as string) objeto,
safe_cast(fundamento_legal as string) fundamento_legal,
safe_cast(modalidade_compra as string) modalidade,
safe_cast(situacao_contrato as string) situacao_contrato,
safe_cast(codigo_orgao_superior as string) id_orgao_superior,
safe_cast(nome_orgao_superior as string) nome_orgao_superior,
safe_cast(codigo_orgao as string) id_orgao,
safe_cast(nome_orgao as string) nome_orgao,
safe_cast(codigo_ug as string) id_unidade_gestora,
safe_cast(nome_ug as string) nome_unidade_gestora,
safe_cast(
parse_date('%d/%m/%Y', data_assinatura_contrato) as date
) data_assinatura_contrato,
safe_cast(parse_date('%d/%m/%Y', data_publicacao_dou) as date) data_publicacao_dou,
safe_cast(
parse_date('%d/%m/%Y', data_inicio_vigencia) as date
) data_inicio_vigencia,
safe_cast(parse_date('%d/%m/%Y', data_fim_vigencia) as date) data_fim_vigencia,
safe_cast(codigo_contratado as string) cpf_cnpj_contratado,
safe_cast(nome_contratado as string) nome_contratado,
safe_cast(numero_licitacao as string) id_licitacao,
safe_cast(codigo_ug_licitacao as string) id_unidade_gestora_licitacao,
safe_cast(nome_ug_licitacao as string) nome_unidade_gestora_licitacao,
safe_cast(codigo_modalidade_compra_licitacao as string) id_modalidade_licitacao,
safe_cast(modalidade_compra_licitacao as string) modalidade_licitacao,
safe_cast(replace(valor_inicial_compra, ",", ".") as float64) valor_inicial_compra,
safe_cast(replace(valor_final_compra, ",", ".") as float64) valor_final_compra,

from `basedosdados-dev.br_cgu_licitacao_contrato_staging.contrato_compra` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
alias="contrato_item",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(numero_contrato as string) id_contrato,
safe_cast(codigo_orgao as string) id_orgao,
safe_cast(nome_orgao as string) nome_orgao,
safe_cast(codigo_ug as string) id_ug,
safe_cast(nome_ug as string) nome_ug,
safe_cast(codigo_item_compra as string) id_item,
safe_cast(descricao_item_compra as string) descricao_item,
safe_cast(descricao_complementar_item_compra as string) descricao_complementar_item,
safe_cast(quantidade_item as int64) quantidade_item,
safe_cast(replace(valor_item, ",", ".") as float64) valor_item,
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.contrato_item` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
alias="contrato_termo_aditivo",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(numero_contrato as string) id_contrato,
safe_cast(codigo_orgao_superior as string) id_orgao_superior,
safe_cast(nome_orgao_superior as string) nome_orgao_superior,
safe_cast(codigo_orgao as string) id_orgao,
safe_cast(nome_orgao as string) nome_orgao,
safe_cast(codigo_ug as string) id_ug,
safe_cast(nome_ug as string) nome_ug,
safe_cast(numero_termo_aditivo as string) id_termo_aditivo,
safe_cast(parse_date('%d/%m/%Y', data_publicacao) as date) data_publicacao_dou,
safe_cast(objeto as string) objeto,
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.contrato_termo_aditivo` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{
config(
alias="licitacao", schema="br_cgu_licitacao_contrato", materialized="table"
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
case when uf = "-3" then null else uf end as sigla_uf,
dir_municipio.id_municipio,
safe_cast(numero_licitacao as string) id_licitacao,
safe_cast(codigo_ug as string) id_unidade_gestora,
safe_cast(nome_ug as string) nome_unidade_gestora,
safe_cast(codigo_modalidade_compra as string) id_modalidade_compra,
safe_cast(modalidade_compra as string) modalidade_compra,
safe_cast(numero_processo as string) numero_processo,
safe_cast(objeto as string) objeto,
safe_cast(situacao_licitacao as string) situacao_licitacao,
safe_cast(codigo_orgao_superior as string) id_orgao_superior,
safe_cast(nome_orgao_superior as string) nome_orgao_superior,
safe_cast(codigo_orgao as string) id_orgao,
safe_cast(nome_orgao as string) nome_orgao,
safe_cast(
parse_date('%d/%m/%Y', data_resultado_compra) as date
) data_resultado_compra,
safe_cast(parse_date('%d/%m/%Y', data_abertura) as date) data_abertura,
safe_cast(replace(valor_licitacao, ",", ".") as float64) valor_licitacao,
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.licitacao` as licitacao
left join
`basedosdados-dev.br_bd_diretorios_brasil.municipio` as dir_municipio
on upper(dir_municipio.nome) = licitacao.municipio
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
alias="licitacao_empenho",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(numero_processo as string) id_processo,
safe_cast(numero_licitacao as string) id_licitacao,
safe_cast(codigo_ug as string) id_unidade_gestora,
safe_cast(nome_ug as string) nome_unidade_gestora,
safe_cast(codigo_modalidade_compra as string) id_modalidade,
safe_cast(modalidade_compra as string) modalidade,
safe_cast(observacao_empenho as string) observacao,
safe_cast(codigo_empenho as string) id_empenho,
safe_cast(parse_date('%d/%m/%Y', data_emissao_empenho) as date) data_emissao,
safe_cast(replace(valor_empenho, ",", ".") as float64) valor,
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.licitacao_empenho` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{
config(
alias="licitacao_item",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(numero_licitacao as string) id_licitacao,
safe_cast(codigo_ug as string) id_unidade_gestora,
safe_cast(nome_ug as string) nome_unidade_gestora,
safe_cast(codigo_modalidade_compra as string) id_modalidade,
safe_cast(modalidade_compra as string) modalidade,
safe_cast(numero_processo as string) numero_processo,
safe_cast(codigo_orgao as string) id_orgao,
safe_cast(nome_orgao as string) nome_orgao,
safe_cast(codigo_vencedor as string) cpf_cnpj_vencedor,
safe_cast(nome_vencedor as string) nome_vencedor,
safe_cast(codigo_item_compra as string) id_item,
safe_cast(descricao as string) descricao_item,
safe_cast(quantidade_item as int64) quantidade_item,
safe_cast(replace(valor_item, ",", ".") as float64) valor_item,
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.licitacao_item` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{
config(
alias="licitacao_participante",
schema="br_cgu_licitacao_contrato",
materialized="table",
)
}}
select
safe_cast(ano as int64) as ano,
safe_cast(mes as int64) as mes,
safe_cast(numero_licitacao as string) as id_licitacao,
safe_cast(codigo_ug as string) as id_unidade_gestora,
safe_cast(nome_ug as string) as nome_unidade_gestora,
safe_cast(codigo_modalidade_compra as string) as id_modalidade_compra,
safe_cast(modalidade_compra as string) as modalidade_compra,
safe_cast(numero_processo as string) as numero_processo,
safe_cast(codigo_orgao as string) as id_orgao,
safe_cast(nome_orgao as string) as nome_orgao,
safe_cast(codigo_item_compra as string) as id_item_compra,
safe_cast(descricao_item_compra as string) as descricao_item_compra,
safe_cast(codigo_participante as string) as cpf_cnpj_participante,
safe_cast(nome_participante as string) as nome_participante,
safe_cast(
case
when flag_vencedor = 'SIM' then true when flag_vencedor = 'NÃO' then false
end as boolean
) as vencedor
from `basedosdados-dev.br_cgu_licitacao_contrato_staging.licitacao_participante`
Loading

0 comments on commit d1848ec

Please sign in to comment.