Skip to content

Commit

Permalink
new linter in model dbt
Browse files Browse the repository at this point in the history
  • Loading branch information
tricktx committed Feb 15, 2024
1 parent f2d2ae5 commit 03e15db
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 90 deletions.
46 changes: 31 additions & 15 deletions models/br_camara_dados_abertos/br_camara_dados_abertos__evento.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
{{ 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
{{ 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
@@ -1,9 +1,8 @@
{{ 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

{{ 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
@@ -1,11 +1,17 @@
{{ 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

{{ 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
@@ -1,7 +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
{{ 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
38 changes: 19 additions & 19 deletions models/br_camara_dados_abertos/br_camara_dados_abertos__frente.sql
Original file line number Diff line number Diff line change
@@ -1,20 +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
{{ 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
@@ -1,14 +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
{{ 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
@@ -1,15 +1,14 @@
{{ 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
{{ 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

0 comments on commit 03e15db

Please sign in to comment.