Skip to content

Commit

Permalink
Merge pull request #534 from basedosdados/br_tse_eleicoes
Browse files Browse the repository at this point in the history
`br_tse_eleicoes`
  • Loading branch information
rdahis authored Jun 5, 2024
2 parents 6218497 + d7eebcd commit 0def2e1
Show file tree
Hide file tree
Showing 22 changed files with 4,007 additions and 441 deletions.
2,501 changes: 2,500 additions & 1 deletion metadata.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion models/br_tse_eleicoes/br_tse_eleicoes__bens_candidato.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"data_type": "int64",
"range": {"start": 2006, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
14 changes: 2 additions & 12 deletions models/br_tse_eleicoes/br_tse_eleicoes__candidatos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"data_type": "int64",
"range": {"start": 1994, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}
-- precisa ser atualizada com as colunas de federação

select
safe_cast(ano as int64) ano,
safe_cast(tipo_eleicao as string) tipo_eleicao,
Expand Down Expand Up @@ -39,14 +38,5 @@ select
safe_cast(sigla_uf_nascimento as string) sigla_uf_nascimento,
safe_cast(municipio_nascimento as string) municipio_nascimento,
safe_cast(email as string) email,
safe_cast(raca as string) raca,
-- SAFE_CAST(situacao_totalizacao AS STRING) situacao_totalizacao,
-- SAFE_CAST(numero_federacao AS STRING) numero_federacao,
-- SAFE_CAST(nome_federacao AS STRING) nome_federacao,
-- SAFE_CAST(sigla_federacao AS STRING) sigla_federacao,
-- SAFE_CAST(composicao_federacao AS STRING) composicao_federacao,
-- CASE
-- WHEN prestou_contas='N' THEN 'Nao'
-- WHEN prestou_contas='S' THEN 'Sim'
-- END AS prestou_contas
safe_cast(raca as string) raca
from `basedosdados-staging.br_tse_eleicoes_staging.candidatos` as t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ select
"data_type": "int64",
"range": {"start": 2002, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{
config(
schema="br_tse_eleicoes",
alias="detalhes_votacao_municipio",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1994, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(cargo as string) cargo,
safe_cast(aptos as int64) aptos,
safe_cast(secoes as int64) secoes,
safe_cast(secoes_agregadas as int64) secoes_agregadas,
safe_cast(aptos_totalizadas as int64) aptos_totalizadas,
safe_cast(secoes_totalizadas as int64) secoes_totalizadas,
safe_cast(comparecimento as int64) comparecimento,
safe_cast(abstencoes as int64) abstencoes,
safe_cast(votos_validos as int64) votos_validos,
safe_cast(votos_brancos as int64) votos_brancos,
safe_cast(votos_nulos as int64) votos_nulos,
safe_cast(votos_nominais as int64) votos_nominais,
safe_cast(votos_legenda as int64) votos_legenda,
safe_cast(proporcao_comparecimento as float64) proporcao_comparecimento,
safe_cast(proporcao_votos_validos as float64) proporcao_votos_validos,
safe_cast(proporcao_votos_brancos as float64) proporcao_votos_brancos,
safe_cast(proporcao_votos_nulos as float64) proporcao_votos_nulos
from `basedosdados-staging.br_tse_eleicoes_staging.detalhes_votacao_municipio` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{
config(
schema="br_tse_eleicoes",
alias="detalhes_votacao_municipio_zona",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1994, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(zona as string) zona,
safe_cast(cargo as string) cargo,
safe_cast(aptos as int64) aptos,
safe_cast(secoes as int64) secoes,
safe_cast(secoes_agregadas as int64) secoes_agregadas,
safe_cast(aptos_totalizadas as int64) aptos_totalizadas,
safe_cast(secoes_totalizadas as int64) secoes_totalizadas,
safe_cast(comparecimento as int64) comparecimento,
safe_cast(abstencoes as int64) abstencoes,
safe_cast(votos_validos as int64) votos_validos,
safe_cast(votos_brancos as int64) votos_brancos,
safe_cast(votos_nulos as int64) votos_nulos,
safe_cast(votos_nominais as int64) votos_nominais,
safe_cast(votos_legenda as int64) votos_legenda,
safe_cast(proporcao_comparecimento as float64) proporcao_comparecimento,
safe_cast(proporcao_votos_validos as float64) proporcao_votos_validos,
safe_cast(proporcao_votos_brancos as float64) proporcao_votos_brancos,
safe_cast(proporcao_votos_nulos as float64) proporcao_votos_nulos
from `basedosdados-staging.br_tse_eleicoes_staging.detalhes_votacao_municipio_zona` as t
39 changes: 39 additions & 0 deletions models/br_tse_eleicoes/br_tse_eleicoes__detalhes_votacao_secao.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{
config(
schema="br_tse_eleicoes",
alias="detalhes_votacao_secao",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1994, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(zona as string) zona,
safe_cast(secao as string) secao,
safe_cast(cargo as string) cargo,
safe_cast(aptos as int64) aptos,
safe_cast(comparecimento as int64) comparecimento,
safe_cast(abstencoes as int64) abstencoes,
safe_cast(votos_nominais as int64) votos_nominais,
safe_cast(votos_brancos as int64) votos_brancos,
safe_cast(votos_nulos as int64) votos_nulos,
safe_cast(votos_coligacao as int64) votos_coligacao,
safe_cast(votos_nulos_apu_sep as int64) votos_nulos_apu_sep,
safe_cast(votos_pendentes as int64) votos_pendentes,
safe_cast(proporcao_comparecimento as float64) proporcao_comparecimento,
safe_cast(proporcao_votos_nominais as float64) proporcao_votos_nominais,
safe_cast(proporcao_votos_coligacao as float64) proporcao_votos_coligacao,
safe_cast(proporcao_votos_brancos as float64) proporcao_votos_brancos,
safe_cast(proporcao_votos_nulos as float64) proporcao_votos_nulos
from `basedosdados-staging.br_tse_eleicoes_staging.detalhes_votacao_secao` as t
15 changes: 15 additions & 0 deletions models/br_tse_eleicoes/br_tse_eleicoes__dicionario.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{
config(
schema="br_tse_eleicoes",
alias="dicionario",
materialized="table",
)
}}

select
safe_cast(id_tabela as string) id_tabela,
safe_cast(nome_coluna as string) nome_coluna,
safe_cast(chave as string) chave,
safe_cast(cobertura_temporal as string) cobertura_temporal,
safe_cast(valor as string) valor,
from `basedosdados-staging.br_tse_eleicoes_staging.dicionario` as t
35 changes: 35 additions & 0 deletions models/br_tse_eleicoes/br_tse_eleicoes__partidos.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{
config(
schema="br_tse_eleicoes",
alias="partidos",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1990, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(cargo as string) cargo,
safe_cast(numero as string) numero,
safe_cast(sigla as string) sigla,
safe_cast(nome as string) nome,
safe_cast(tipo_agremiacao as string) tipo_agremiacao,
safe_cast(sequencial_coligacao as string) sequencial_coligacao,
safe_cast(nome_coligacao as string) nome_coligacao,
safe_cast(composicao_coligacao as string) composicao_coligacao,
safe_cast(numero_federacao as string) numero_federacao,
safe_cast(nome_federacacao as string) nome_federacacao,
safe_cast(sigla_federacao as string) sigla_federacao,
safe_cast(composicao_federacao as string) composicao_federacao,
safe_cast(situacao_legenda as string) situacao_legenda
from `basedosdados-staging.br_tse_eleicoes_staging.partidos` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{
config(
schema="br_tse_eleicoes",
alias="perfil_eleitorado_local_votacao",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2016, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(zona as string) zona,
safe_cast(secao as string) secao,
safe_cast(tipo_secao_agregada as string) tipo_secao_agregada,
safe_cast(numero as string) numero,
safe_cast(nome as string) nome,
safe_cast(tipo as string) tipo,
safe_cast(endereco as string) endereco,
safe_cast(bairro as string) bairro,
safe_cast(cep as string) cep,
safe_cast(telefone as string) telefone,
safe_cast(latitude as float64) latitude,
safe_cast(longitude as float64) longitude,
safe_cast(situacao as string) situacao,
safe_cast(situacao_zona as string) situacao_zona,
safe_cast(situacao_secao as string) situacao_secao,
safe_cast(situacao_localidade as string) situacao_localidade,
safe_cast(situacao_secao_acessibilidade as string) situacao_secao_acessibilidade,
safe_cast(eleitores_secao as int64) eleitores_secao,
from `basedosdados-staging.br_tse_eleicoes_staging.perfil_eleitorado_local_votacao` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{
config(
schema="br_tse_eleicoes",
alias="perfil_eleitorado_municipio_zona",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1998, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(situacao_biometria as string) situacao_biometria,
safe_cast(zona as string) zona,
safe_cast(genero as string) genero,
safe_cast(estado_civil as string) estado_civil,
safe_cast(grupo_idade as string) grupo_idade,
safe_cast(instrucao as string) instrucao,
safe_cast(eleitores as string) eleitores,
safe_cast(eleitores_biometria as string) eleitores_biometria,
safe_cast(eleitores_deficiencia as string) eleitores_deficiencia
from
`basedosdados-staging.br_tse_eleicoes_staging.perfil_eleitorado_municipio_zona` as t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{
config(
schema="br_tse_eleicoes",
alias="perfil_eleitorado_secao",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2008, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(situacao_biometria as string) situacao_biometria,
safe_cast(zona as string) zona,
safe_cast(secao as string) secao,
safe_cast(genero as string) genero,
safe_cast(estado_civil as string) estado_civil,
safe_cast(grupo_idade as string) grupo_idade,
safe_cast(instrucao as string) instrucao,
safe_cast(eleitores as string) eleitores,
safe_cast(eleitores_biometria as string) eleitores_biometria,
safe_cast(eleitores_deficiencia as string) eleitores_deficiencia,
safe_cast(eleitores_inclusao_nome_social as string) eleitores_inclusao_nome_social
from `basedosdados-staging.br_tse_eleicoes_staging.perfil_eleitorado_secao` as t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"data_type": "int64",
"range": {"start": 2002, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"data_type": "int64",
"range": {"start": 2002, "end": 2014, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"data_type": "int64",
"range": {"start": 2010, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"data_type": "int64",
"range": {"start": 1945, "end": 2022, "interval": 1},
},
cluster_by=["sigla_uf"],
)
}}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{
config(
schema="br_tse_eleicoes",
alias="resultados_candidato_municipio",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 1998, "end": 2022, "interval": 2},
},
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(id_municipio as string) id_municipio,
safe_cast(id_municipio_tse as string) id_municipio_tse,
safe_cast(cargo as string) cargo,
safe_cast(numero_partido as string) numero_partido,
safe_cast(sigla_partido as string) sigla_partido,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(resultado as string) resultado,
safe_cast(votos as int64) votos
from `basedosdados-staging.br_tse_eleicoes_staging.resultados_candidato_municipio` as t
Loading

0 comments on commit 0def2e1

Please sign in to comment.