Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dbt] br_camara_dados_abertos #439

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading