Skip to content

Commit

Permalink
Merge pull request #439 from basedosdados/br-camara-dados
Browse files Browse the repository at this point in the history
[dbt] br_camara_dados_abertos
  • Loading branch information
tricktx authored Feb 20, 2024
2 parents 4853f68 + 62c286c commit d2fc431
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 2 deletions.
30 changes: 30 additions & 0 deletions models/br_camara_dados_abertos/br_camara_dados_abertos__evento.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ config(alias="evento", schema="br_camara_dados_abertos") }}
select
safe_cast(id as string) id,
safe_cast(urldocumentopauta as string) url_documento_pauta,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorainicio)), 'T')[
offset(0)
] as date
) data_inicio,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorainicio)), 'T')[
offset(1)
] as time
) horario_inicio,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorafim)), 'T')[
offset(0)
] as date
) data_final,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorafim)), 'T')[
offset(1)
] as time
) horario_final,
safe_cast(situacao as string) situacao,
safe_cast(descricao as string) descricao,
safe_cast(descricaotipo as string) tipo,
safe_cast(localexterno as string) local_externo,
safe_cast(localcamara_nome as string) nome_local,
from `basedosdados-staging.br_camara_dados_abertos_staging.evento` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ config(alias="evento_orgao", schema="br_camara_dados_abertos") }}
select
safe_cast(idevento as string) id_evento,
safe_cast(idorgao as string) id_orgao,
safe_cast(siglaorgao as string) sigla_orgao,
from `basedosdados-staging.br_camara_dados_abertos_staging.evento_orgao` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ config(alias="evento_presenca_deputado", schema="br_camara_dados_abertos") }}
select distinct
safe_cast(idevento as string) id_evento,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorainicio)), 'T')[
offset(0)
] as date
) data_inicio,
safe_cast(
split(format_timestamp('%Y-%m-%dT%H:%M:%E*S', timestamp(datahorainicio)), 'T')[
offset(1)
] as time
) horario_inicio,
safe_cast(iddeputado as string) id_deputado,
from
`basedosdados-staging.br_camara_dados_abertos_staging.evento_presenca_deputado` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ config(alias="evento_requerimento", schema="br_camara_dados_abertos") }}
select
safe_cast(idevento as string) id_evento,
safe_cast(titulorequerimento as string) titulo_requerimento,
regexp_extract(urirequerimento, r'/([^/]+)$') id_proposicao
from `basedosdados-staging.br_camara_dados_abertos_staging.evento_requerimento` as t
13 changes: 13 additions & 0 deletions models/br_camara_dados_abertos/br_camara_dados_abertos__frente.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ config(alias="frente", schema="br_camara_dados_abertos") }}
select
safe_cast(id as string) id,
safe_cast(titulo as string) titulo,
safe_cast(datacriacao as date) data_criacao,
safe_cast(idlegislatura as string) id_legislatura,
safe_cast(telefone as string) telefone,
safe_cast(situacao as string) situacao,
safe_cast(urldocumento as string) url_documento,
safe_cast(coordenador_id as string) id_coordenador,
safe_cast(coordenador_nome as string) nome_coordenador,
safe_cast(coordenador_urlfoto as string) url_foto_coordenador,
from `basedosdados-staging.br_camara_dados_abertos_staging.frente` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ config(alias="frente_deputado", schema="br_camara_dados_abertos") }}
select
safe_cast(id as string) id_frente,
safe_cast(titulo as string) titulo,
safe_cast(id_deputado as string) id_deputado,
initcap(nome_deputado) nome_deputado,
safe_cast(titulo_deputado as string) titulo_deputado,
safe_cast(url_foto_deputado as string) url_foto_deputado,
from `basedosdados-staging.br_camara_dados_abertos_staging.frente_deputado` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ config(alias="funcionario", schema="br_camara_dados_abertos") }}
select distinct
safe_cast(nome as string) nome,
safe_cast(cargo as string) cargo,
safe_cast(funcao as string) funcao,
safe_cast(datainiciohistorico as date) data_inicio_historico,
safe_cast(datanomeacao as date) data_nomeacao,
safe_cast(datapubnomeacao as date) data_publicacao_nomeacao,
safe_cast(grupo as string) grupo,
safe_cast(ponto as string) ponto,
safe_cast(atonomeacao as string) ato_nomeacao,
safe_cast(lotacao as string) lotacao,
from `basedosdados-staging.br_camara_dados_abertos_staging.funcionario` as t
Loading

0 comments on commit d2fc431

Please sign in to comment.