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/fix] br_bd_diretorios_brasil.cep #147

Merged
merged 2 commits into from
Aug 1, 2023
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
23 changes: 23 additions & 0 deletions models/br_bd_diretorios_brasil/cep.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{
config(
schema='br_bd_diretorios_brasil',
materialized='table',
partition_by={
"field": "sigla_uf",
"data_type": "string",
}
)
}}

SELECT
SAFE_CAST(lpad(cep, 8, '0') AS STRING) cep,
SAFE_CAST(logradouro AS STRING) logradouro,
SAFE_CAST(complemento AS STRING) complemento,
SAFE_CAST(bairro AS STRING) bairro,
SAFE_CAST(cidade AS STRING) cidade,
SAFE_CAST(id_municipio AS STRING) id_municipio,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
SAFE_CAST(latitude AS FLOAT64) latitude,
SAFE_CAST(longitude AS FLOAT64) longitude,
ST_GEOGPOINT(SAFE_CAST(longitude AS FLOAT64),SAFE_CAST(latitude AS FLOAT64)) centroide
FROM basedosdados-staging.br_bd_diretorios_brasil_staging.cep AS t
27 changes: 27 additions & 0 deletions models/br_bd_diretorios_brasil/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,30 @@ models:
description: Fax (con DDD)
- name: email
description: Email
- name: cep
description: "Na tabela, é possível encontrar a numeração dos CEPs, juntamente com
informações sobre suas localidades, tais como logradouros, bairros e cidades,
além de complementos e identificação geográfica compostos pela latitude e longitude.
Os dados foram obtidos através de uma base aberta no Kaggle e validados em relação
aos seus pontos de geolocalização."
columns:
- name: cep
description: Número do CEP
- name: logradouro
description: Logradouro
- name: complemento
description: Complemento do endereço
- name: bairro
description: Bairro
- name: cidade
description: Nome da cidade, distrito ou município
- name: id_municipio
description: ID Município - IBGE 7 Dígitos
- name: sigla_uf
description: Sigla da Unidade da Federação
- name: latitude
description: Latitude do CEP
- name: longitude
description: Longitude do CEP
- name: centroide
description: Centróide do CEP
Loading