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

feat: update data elections 2024, id_candidato_bd -> titulo_eleitoral #628

Merged
merged 3 commits into from
Nov 21, 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
3 changes: 1 addition & 2 deletions models/br_tse_eleicoes/br_tse_eleicoes__bens_candidato.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ select
safe_cast(id_eleicao as string) id_eleicao,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(data_eleicao as date) data_eleicao,
safe_cast(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(id_tipo_item as string) id_tipo_item,
safe_cast(tipo_item as string) tipo_item,
safe_cast(descricao_item as string) descricao_item,
safe_cast(valor_item as float64) valor_item
Expand Down
5 changes: 2 additions & 3 deletions models/br_tse_eleicoes/br_tse_eleicoes__candidatos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ select
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,
cast(split(id_candidato_bd, '.')[offset(0)] as string) id_candidato_bd,
cast(split(cpf, '.')[offset(0)] as string) cpf,
safe_cast(titulo_eleitoral as string) titulo_eleitoral,
cast(split(cpf, '.')[offset(0)] as string) cpf,
safe_cast(sequencial as string) sequencial,
safe_cast(numero as string) numero,
safe_cast(nome as string) nome,
Expand All @@ -30,11 +29,11 @@ select
safe_cast(sigla_partido as string) sigla_partido,
safe_cast(cargo as string) cargo,
safe_cast(situacao as string) situacao,
safe_cast(ocupacao as string) ocupacao,
safe_cast(data_nascimento as date) data_nascimento,
cast(split(idade, '.')[offset(0)] as int64) idade,
safe_cast(genero as string) genero,
safe_cast(instrucao as string) instrucao,
safe_cast(ocupacao as string) ocupacao,
safe_cast(estado_civil as string) estado_civil,
safe_cast(nacionalidade as string) nacionalidade,
safe_cast(sigla_uf_nascimento as string) sigla_uf_nascimento,
Expand Down
11 changes: 3 additions & 8 deletions models/br_tse_eleicoes/br_tse_eleicoes__despesas_candidato.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ select
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(numero_candidato as string) numero_candidato,
safe_cast(cpf_candidato as string) cpf_candidato,
safe_cast(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(nome_candidato as string) nome_candidato,
safe_cast(cpf_vice_suplente as string) cpf_vice_suplente,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(cnpj_candidato as string) cnpj_candidato,
safe_cast(numero_partido as string) numero_partido,
safe_cast(sigla_partido as string) sigla_partido,
safe_cast(nome_partido as string) nome_partido,
safe_cast(cargo as string) cargo,
safe_cast(sequencial_despesa as string) sequencial_despesa,
safe_cast(data_despesa as date) data_despesa,
Expand All @@ -40,7 +37,6 @@ select
safe_cast(data_prestacao_contas as date) data_prestacao_contas,
safe_cast(sequencial_prestador_contas as string) sequencial_prestador_contas,
safe_cast(cnpj_prestador_contas as string) cnpj_prestador_contas,
safe_cast(cnpj_candidato as string) cnpj_candidato,
safe_cast(tipo_documento as string) tipo_documento,
safe_cast(numero_documento as string) numero_documento,
safe_cast(especie_recurso as string) especie_recurso,
Expand Down Expand Up @@ -70,6 +66,5 @@ select
safe_cast(numero_candidato_fornecedor as string) numero_candidato_fornecedor,
safe_cast(numero_partido_fornecedor as string) numero_partido_fornecedor,
safe_cast(sigla_partido_fornecedor as string) sigla_partido_fornecedor,
safe_cast(nome_partido_fornecedor as string) nome_partido_fornecedor,
safe_cast(cargo_fornecedor as string) cargo_fornecedor
from `basedosdados-dev.br_tse_eleicoes_staging.despesas_candidato` as t
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{{
config(
schema='br_tse_eleicoes',
alias = 'detalhes_votacao_municipio',
materialized='table',
schema="br_tse_eleicoes",
alias="detalhes_votacao_municipio",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {
"start": 1994,
"end": 2022,
"interval": 2
}
"range": {"start": 1994, "end": 2024, "interval": 2},
},
cluster_by=["sigla_uf"],
)
Expand All @@ -19,7 +15,9 @@
select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(id_eleicao as string) id_eleicao,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(data_eleicao as date) data_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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{{
config(
schema='br_tse_eleicoes',
alias = 'detalhes_votacao_municipio_zona',
materialized='table',
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
}
"range": {"start": 1994, "end": 2024, "interval": 2},
},
cluster_by=["sigla_uf"],
)
Expand All @@ -19,7 +15,9 @@
select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
safe_cast(id_eleicao as string) id_eleicao,
safe_cast(tipo_eleicao as string) tipo_eleicao,
safe_cast(data_eleicao as date) data_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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 1994,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
2 changes: 1 addition & 1 deletion models/br_tse_eleicoes/br_tse_eleicoes__partidos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 1990,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 2016,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 1998,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 2008,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
13 changes: 4 additions & 9 deletions models/br_tse_eleicoes/br_tse_eleicoes__receitas_candidato.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ select
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(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(cpf_candidato as string) cpf_candidato,
safe_cast(cnpj_candidato as string) cnpj_candidato,
safe_cast(titulo_eleitor_candidato as string) titulo_eleitor_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(nome_candidato as string) nome_candidato,
safe_cast(cpf_vice_suplente as string) cpf_vice_suplente,
safe_cast(numero_partido as string) numero_partido,
safe_cast(nome_partido as string) nome_partido,
safe_cast(sigla_partido as string) sigla_partido,
safe_cast(cargo as string) cargo,
safe_cast(sequencial_receita as string) sequencial_receita,
safe_cast(data_receita as date) data_receita,
{{ validate_date_range("data_receita", "1900-01-01", "2100-01-01") }}
as data_receita,
safe_cast(fonte_receita as string) fonte_receita,
safe_cast(origem_receita as string) origem_receita,
safe_cast(natureza_receita as string) natureza_receita,
Expand All @@ -49,7 +45,6 @@ select
safe_cast(cargo_candidato_doador as string) cargo_candidato_doador,
safe_cast(numero_partido_doador as string) numero_partido_doador,
safe_cast(sigla_partido_doador as string) sigla_partido_doador,
safe_cast(nome_partido_doador as string) nome_partido_doador,
safe_cast(esfera_partidaria_doador as string) esfera_partidaria_doador,
safe_cast(numero_candidato_doador as string) numero_candidato_doador,
safe_cast(cnae_2_doador as string) cnae_2_doador,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ select
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(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(nome_candidato as string) nome_candidato,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(resultado as string) resultado,
safe_cast(votos as int64) votos
from `basedosdados-dev.br_tse_eleicoes_staging.resultados_candidato` as t
from `basedosdados-dev.br_tse_eleicoes_staging.resultados_candidato` as t
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ select
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(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(resultado as string) resultado,
safe_cast(votos as int64) votos
from `basedosdados-dev.br_tse_eleicoes_staging.resultados_candidato_municipio` as t
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ select
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(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(resultado as string) resultado,
safe_cast(votos as int64) votos
from `basedosdados-dev.br_tse_eleicoes_staging.resultados_candidato_municipio_zona` as t
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ select
safe_cast(cargo as string) cargo,
safe_cast(numero_partido as string) numero_partido,
safe_cast(sigla_partido as string) sigla_partido,
safe_cast(titulo_eleitoral_candidato as string) titulo_eleitoral_candidato,
safe_cast(sequencial_candidato as string) sequencial_candidato,
safe_cast(numero_candidato as string) numero_candidato,
safe_cast(id_candidato_bd as string) id_candidato_bd,
safe_cast(votos as int64) votos
from `basedosdados-dev.br_tse_eleicoes_staging.resultados_candidato_secao` as t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
cluster_by=["sigla_uf"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(turno as int64) turno,
Expand Down
2 changes: 1 addition & 1 deletion models/br_tse_eleicoes/br_tse_eleicoes__vagas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data_type": "int64",
"range": {
"start": 1994,
"end": 2022,
"end": 2024,
"interval": 2
}
},
Expand Down
Loading
Loading