-
Notifications
You must be signed in to change notification settings - Fork 1
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 #631 from basedosdados/cgu_licitacao_contrato
[dbt] br_cgu_licitacao_contrato
- Loading branch information
Showing
9 changed files
with
540 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
40 changes: 40 additions & 0 deletions
40
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__contrato_compra.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,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 |
21 changes: 21 additions & 0 deletions
21
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__contrato_item.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,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 |
21 changes: 21 additions & 0 deletions
21
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__contrato_termo_aditivo.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,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 |
31 changes: 31 additions & 0 deletions
31
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__licitacao.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,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 |
21 changes: 21 additions & 0 deletions
21
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__licitacao_empenho.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,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 |
25 changes: 25 additions & 0 deletions
25
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__licitacao_item.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,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 |
28 changes: 28 additions & 0 deletions
28
models/br_cgu_licitacao_contrato/br_cgu_licitacao_contrato__licitacao_participante.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,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` |
Oops, something went wrong.