Skip to content

Commit

Permalink
add model dbt now
Browse files Browse the repository at this point in the history
  • Loading branch information
tricktx committed Feb 15, 2024
1 parent 4bb19ed commit f2d2ae5
Show file tree
Hide file tree
Showing 8 changed files with 707 additions and 204 deletions.
15 changes: 15 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,15 @@
{{ config(alias='evento',schema='br_camara_dados_abertos') }}
SELECT
SAFE_CAST(id AS STRING) id,
SAFE_CAST(uri AS STRING) url,
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,9 @@
{{ config(alias='evento_orgao',schema='br_camara_dados_abertos') }}
SELECT
SAFE_CAST(idEvento AS STRING) id,
SAFE_CAST(uriEvento AS STRING) url,
SAFE_CAST(idOrgao AS STRING) id_orgao,
SAFE_CAST(siglaOrgao AS STRING) sigla_orgao,
SAFE_CAST(uriOrgao AS STRING) url_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,11 @@
{{ config(alias='evento_presenca_deputado',schema='br_camara_dados_abertos') }}
SELECT
DISTINCT
SAFE_CAST(idEvento AS STRING) id,
SAFE_CAST(uriEvento AS STRING) url,
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,
SAFE_CAST(uriDeputado AS STRING) url_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,7 @@
{{ config(alias='evento_requerimento',schema='br_camara_dados_abertos') }}
SELECT
SAFE_CAST(idEvento AS STRING) id,
SAFE_CAST(uriEvento AS STRING) url,
SAFE_CAST(tituloRequerimento AS STRING) titulo_requerimento,
SAFE_CAST(uriRequerimento AS STRING) url_requerimento,
FROM basedosdados-staging.br_camara_dados_abertos_staging.evento_requerimento AS t
20 changes: 20 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,20 @@
{{ config(alias='frente',schema='br_camara_dados_abertos') }}
SELECT
SAFE_CAST(id AS STRING) id,
SAFE_CAST(uri AS STRING) url,
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,
SAFE_CAST(coordenador_uri AS STRING) url_coordenador,
SAFE_CAST(coordenador_siglaUf AS STRING) sigla_uf_coordenador,
SAFE_CAST(coordenador_idLegislatura AS STRING) id_legislatura_coordenador,
SAFE_CAST(coordenador_siglaPartido AS STRING) sigla_partido_coordenador,
SAFE_CAST(coordenador_uriPartido AS STRING) url_partido_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,14 @@
{{ config(alias='frente_deputado',schema='br_camara_dados_abertos') }}
SELECT
SAFE_CAST(id AS STRING) id,
SAFE_CAST(uri AS STRING) url,
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(sigla_uf_deputado AS STRING) sigla_uf_deputado,
SAFE_CAST(url_deputado AS STRING) url_deputado,
SAFE_CAST(url_partido_deputado AS STRING) url_partido_deputado,
SAFE_CAST(id_legislatura_deputado AS STRING) id_legislatura_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,15 @@
{{ 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,
SAFE_CAST(uriLotacao AS STRING) url_lotacao,
FROM basedosdados-staging.br_camara_dados_abertos_staging.funcionario AS t
Loading

0 comments on commit f2d2ae5

Please sign in to comment.