-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from basedosdados/staging/br_ibgr_censo
[dbt] br_ibge_censo_demografico
- Loading branch information
Showing
35 changed files
with
17,355 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
models/br_ibge_censo_demografico/br_ibge_censo_demografico__dicionario.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{ | ||
config( | ||
alias = 'dicionario', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_tabela AS STRING) id_tabela, | ||
SAFE_CAST(nome_coluna AS STRING) nome_coluna, | ||
SAFE_CAST(REPLACE(chave,".0","") AS STRING) chave, | ||
SAFE_CAST(cobertura_temporal AS STRING) cobertura_temporal, | ||
SAFE_CAST(valor AS STRING) valor | ||
FROM basedosdados-staging.br_ibge_censo_demografico_staging.dicionario AS t |
40 changes: 40 additions & 0 deletions
40
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_domicilio_1970.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{ | ||
config( | ||
alias='microdados_domicilio_1970', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(id_domicilio AS STRING) id_domicilio, | ||
SAFE_CAST(numero_familia AS INT64) numero_familia, | ||
SAFE_CAST(v001 AS STRING) v001, | ||
SAFE_CAST(v002 AS STRING) v002, | ||
SAFE_CAST(v003 AS STRING) v003, | ||
SAFE_CAST(v004 AS STRING) v004, | ||
SAFE_CAST(v005 AS INT64) v005, | ||
SAFE_CAST(v006 AS STRING) v006, | ||
SAFE_CAST(v007 AS STRING) v007, | ||
SAFE_CAST(v008 AS STRING) v008, | ||
SAFE_CAST(v009 AS STRING) v009, | ||
SAFE_CAST(v010 AS STRING) v010, | ||
SAFE_CAST(v011 AS STRING) v011, | ||
SAFE_CAST(v012 AS STRING) v012, | ||
SAFE_CAST(v013 AS STRING) v013, | ||
SAFE_CAST(v014 AS STRING) v014, | ||
SAFE_CAST(v015 AS STRING) v015, | ||
SAFE_CAST(v016 AS STRING) v016, | ||
SAFE_CAST(v017 AS STRING) v017, | ||
SAFE_CAST(v018 AS STRING) v018, | ||
SAFE_CAST(v019 AS STRING) v019, | ||
SAFE_CAST(v020 AS INT64) v020, | ||
SAFE_CAST(v021 AS INT64) v021, | ||
SAFE_CAST(v054 AS INT64) v054 | ||
FROM basedosdados-staging.br_ibge_censo_demografico_staging.microdados_domicilio_1970 AS t |
39 changes: 39 additions & 0 deletions
39
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_domicilio_1980.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{ | ||
config( | ||
alias='microdados_domicilio_1980', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(id_distrito AS STRING) id_distrito, | ||
SAFE_CAST(v201 AS STRING) v201, | ||
SAFE_CAST(v202 AS STRING) v202, | ||
SAFE_CAST(v203 AS STRING) v203, | ||
SAFE_CAST(v204 AS STRING) v204, | ||
SAFE_CAST(v205 AS STRING) v205, | ||
SAFE_CAST(v206 AS STRING) v206, | ||
SAFE_CAST(v207 AS STRING) v207, | ||
SAFE_CAST(v208 AS STRING) v208, | ||
SAFE_CAST(v209 AS STRING) v209, | ||
SAFE_CAST(v602 AS INT64) v602, | ||
SAFE_CAST(v212 AS INT64) v212, | ||
SAFE_CAST(v213 AS INT64) v213, | ||
SAFE_CAST(v214 AS STRING) v214, | ||
SAFE_CAST(v215 AS STRING) v215, | ||
SAFE_CAST(v216 AS STRING) v216, | ||
SAFE_CAST(v217 AS STRING) v217, | ||
SAFE_CAST(v218 AS STRING) v218, | ||
SAFE_CAST(v219 AS STRING) v219, | ||
SAFE_CAST(v220 AS STRING) v220, | ||
SAFE_CAST(v221 AS STRING) v221, | ||
SAFE_CAST(v198 AS INT64) v198, | ||
SAFE_CAST(v603 AS INT64) v603, | ||
SAFE_CAST(v598 AS STRING) v598 | ||
from basedosdados-staging.br_ibge_censo_demografico_staging.microdados_domicilio_1980 as t |
56 changes: 56 additions & 0 deletions
56
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_domicilio_1991.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{ | ||
config( | ||
alias='microdados_domicilio_1991', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(id_questionario AS STRING) id_questionario, | ||
SAFE_CAST(peso_amostral AS FLOAT64) peso_amostral, | ||
SAFE_CAST(v0109 AS STRING) v0109, | ||
SAFE_CAST(v1061 AS STRING) v1061, | ||
SAFE_CAST(v7003 AS STRING) v7003, | ||
SAFE_CAST(v0111 AS INT64) v0111, | ||
SAFE_CAST(v0112 AS STRING) v0112, | ||
SAFE_CAST(v0201 AS STRING) v0201, | ||
SAFE_CAST(v2012 AS INT64) v2012, | ||
SAFE_CAST(v2013 AS STRING) v2013, | ||
SAFE_CAST(v2014 AS STRING) v2014, | ||
SAFE_CAST(v0202 AS STRING) v0202, | ||
SAFE_CAST(v0203 AS STRING) v0203, | ||
SAFE_CAST(v0204 AS STRING) v0204, | ||
SAFE_CAST(v0205 AS STRING) v0205, | ||
SAFE_CAST(v0206 AS STRING) v0206, | ||
SAFE_CAST(v0207 AS STRING) v0207, | ||
SAFE_CAST(v0208 AS STRING) v0208, | ||
SAFE_CAST(v0209 AS INT64) v0209, | ||
SAFE_CAST(v2094 AS STRING) v2094, | ||
SAFE_CAST(v0210 AS STRING) v0210, | ||
SAFE_CAST(v0211 AS INT64) v0211, | ||
SAFE_CAST(v2111 AS INT64) v2111, | ||
SAFE_CAST(v2112 AS STRING) v2112, | ||
SAFE_CAST(v0212 AS INT64) v0212, | ||
SAFE_CAST(v2121 AS INT64) v2121, | ||
SAFE_CAST(v2122 AS STRING) v2122, | ||
SAFE_CAST(v0213 AS INT64) v0213, | ||
SAFE_CAST(v0214 AS STRING) v0214, | ||
SAFE_CAST(v0216 AS STRING) v0216, | ||
SAFE_CAST(v0217 AS STRING) v0217, | ||
SAFE_CAST(v0218 AS STRING) v0218, | ||
SAFE_CAST(v0219 AS STRING) v0219, | ||
SAFE_CAST(v0220 AS STRING) v0220, | ||
SAFE_CAST(v0221 AS STRING) v0221, | ||
SAFE_CAST(v0222 AS STRING) v0222, | ||
SAFE_CAST(v0223 AS STRING) v0223, | ||
SAFE_CAST(v0224 AS STRING) v0224, | ||
SAFE_CAST(v0225 AS STRING) v0225, | ||
SAFE_CAST(v0226 AS STRING) v0226, | ||
SAFE_CAST(v0227 AS STRING) v0227 | ||
from basedosdados-staging.br_ibge_censo_demografico_staging.microdados_domicilio_1991 as t |
69 changes: 69 additions & 0 deletions
69
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_domicilio_2000.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{{ | ||
config( | ||
alias='microdados_domicilio_2000', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_regiao AS STRING) id_regiao, | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_mesorregiao AS STRING) id_mesorregiao, | ||
SAFE_CAST(id_microrregiao AS STRING) id_microrregiao, | ||
SAFE_CAST(id_regiao_metropolitana AS STRING) id_regiao_metropolitana, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(id_distrito AS STRING) id_distrito, | ||
SAFE_CAST(id_subdistrito AS STRING) id_subdistrito, | ||
SAFE_CAST(controle AS INT64) controle, | ||
SAFE_CAST(situacao_setor AS INT64) situacao_setor, | ||
SAFE_CAST(situacao_domicilio AS INT64) situacao_domicilio, | ||
SAFE_CAST(tipo_setor AS STRING) tipo_setor, | ||
SAFE_CAST(peso_amostral AS FLOAT64) peso_amostral, | ||
SAFE_CAST(area_ponderacao AS INT64) area_ponderacao, | ||
SAFE_CAST(v0110 AS INT64) v0110, | ||
SAFE_CAST(v0111 AS INT64) v0111, | ||
SAFE_CAST(v0201 AS STRING) v0201, | ||
SAFE_CAST(v0202 AS STRING) v0202, | ||
SAFE_CAST(v0203 AS INT64) v0203, | ||
SAFE_CAST(v0204 AS INT64) v0204, | ||
SAFE_CAST(v0205 AS STRING) v0205, | ||
SAFE_CAST(v0206 AS STRING) v0206, | ||
SAFE_CAST(v0207 AS STRING) v0207, | ||
SAFE_CAST(v0208 AS STRING) v0208, | ||
SAFE_CAST(v0209 AS STRING) v0209, | ||
SAFE_CAST(v0210 AS STRING) v0210, | ||
SAFE_CAST(v0211 AS STRING) v0211, | ||
SAFE_CAST(v0212 AS STRING) v0212, | ||
SAFE_CAST(v0213 AS STRING) v0213, | ||
SAFE_CAST(v0214 AS STRING) v0214, | ||
SAFE_CAST(v0215 AS STRING) v0215, | ||
SAFE_CAST(v0216 AS STRING) v0216, | ||
SAFE_CAST(v0217 AS STRING) v0217, | ||
SAFE_CAST(v0218 AS STRING) v0218, | ||
SAFE_CAST(v0219 AS STRING) v0219, | ||
SAFE_CAST(v0220 AS STRING) v0220, | ||
SAFE_CAST(v0221 AS STRING) v0221, | ||
SAFE_CAST(v0222 AS STRING) v0222, | ||
SAFE_CAST(v0223 AS STRING) v0223, | ||
SAFE_CAST(v7100 AS INT64) v7100, | ||
SAFE_CAST(v7203 AS FLOAT64) v7203, | ||
SAFE_CAST(v7204 AS FLOAT64) v7204, | ||
SAFE_CAST(v7401 AS INT64) v7401, | ||
SAFE_CAST(v7402 AS INT64) v7402, | ||
SAFE_CAST(v7403 AS INT64) v7403, | ||
SAFE_CAST(v7404 AS INT64) v7404, | ||
SAFE_CAST(v7405 AS INT64) v7405, | ||
SAFE_CAST(v7406 AS INT64) v7406, | ||
SAFE_CAST(v7407 AS INT64) v7407, | ||
SAFE_CAST(v7408 AS INT64) v7408, | ||
SAFE_CAST(v7409 AS INT64) v7409, | ||
SAFE_CAST(v7616 AS INT64) v7616, | ||
SAFE_CAST(v7617 AS INT64) v7617, | ||
SAFE_CAST(v1111 AS STRING) v1111, | ||
SAFE_CAST(v1112 AS STRING) v1112, | ||
SAFE_CAST(v1113 AS STRING) v1113 | ||
from basedosdados-staging.br_ibge_censo_demografico_staging.microdados_domicilio_2000 as t |
89 changes: 89 additions & 0 deletions
89
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_domicilio_2010.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{{ | ||
config( | ||
alias='microdados_domicilio_2010', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_regiao AS STRING) id_regiao, | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_mesorregiao AS STRING) id_mesorregiao, | ||
SAFE_CAST(id_microrregiao AS STRING) id_microrregiao, | ||
SAFE_CAST(id_regiao_metropolitana AS STRING) id_regiao_metropolitana, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(situacao_setor AS INT64) situacao_setor, | ||
SAFE_CAST(situacao_domicilio AS INT64) situacao_domicilio, | ||
SAFE_CAST(controle AS INT64) controle, | ||
SAFE_CAST(peso_amostral AS FLOAT64) peso_amostral, | ||
SAFE_CAST(area_ponderacao AS INT64) area_ponderacao, | ||
SAFE_CAST(v4001 AS STRING) v4001, | ||
SAFE_CAST(v4002 AS STRING) v4002, | ||
SAFE_CAST(v0201 AS STRING) v0201, | ||
SAFE_CAST(v2011 AS STRING) v2011, | ||
SAFE_CAST(v2012 AS FLOAT64) v2012, | ||
SAFE_CAST(v0202 AS STRING) v0202, | ||
SAFE_CAST(v0203 AS STRING) v0203, | ||
SAFE_CAST(v6203 AS FLOAT64) v6203, | ||
SAFE_CAST(v0204 AS INT64) v0204, | ||
SAFE_CAST(v6204 AS FLOAT64) v6204, | ||
SAFE_CAST(v0205 AS STRING) v0205, | ||
SAFE_CAST(v0206 AS STRING) v0206, | ||
SAFE_CAST(v0207 AS STRING) v0207, | ||
SAFE_CAST(v0208 AS STRING) v0208, | ||
SAFE_CAST(v0209 AS STRING) v0209, | ||
SAFE_CAST(v0210 AS STRING) v0210, | ||
SAFE_CAST(v0211 AS STRING) v0211, | ||
SAFE_CAST(v0212 AS STRING) v0212, | ||
SAFE_CAST(v0213 AS STRING) v0213, | ||
SAFE_CAST(v0214 AS STRING) v0214, | ||
SAFE_CAST(v0215 AS STRING) v0215, | ||
SAFE_CAST(v0216 AS STRING) v0216, | ||
SAFE_CAST(v0217 AS STRING) v0217, | ||
SAFE_CAST(v0218 AS STRING) v0218, | ||
SAFE_CAST(v0219 AS STRING) v0219, | ||
SAFE_CAST(v0220 AS STRING) v0220, | ||
SAFE_CAST(v0221 AS STRING) v0221, | ||
SAFE_CAST(v0222 AS STRING) v0222, | ||
SAFE_CAST(v0301 AS STRING) v0301, | ||
SAFE_CAST(v0401 AS STRING) v0401, | ||
SAFE_CAST(v0402 AS STRING) v0402, | ||
SAFE_CAST(v0701 AS STRING) v0701, | ||
SAFE_CAST(v6529 AS INT64) v6529, | ||
SAFE_CAST(v6530 AS FLOAT64) v6530, | ||
SAFE_CAST(v6531 AS INT64) v6531, | ||
SAFE_CAST(v6532 AS FLOAT64) v6532, | ||
SAFE_CAST(v6600 AS INT64) v6600, | ||
SAFE_CAST(v6210 AS INT64) v6210, | ||
SAFE_CAST(m0201 AS STRING) m0201, | ||
SAFE_CAST(m02011 AS STRING) m02011, | ||
SAFE_CAST(m0202 AS STRING) m0202, | ||
SAFE_CAST(m0203 AS STRING) m0203, | ||
SAFE_CAST(m0204 AS STRING) m0204, | ||
SAFE_CAST(m0205 AS STRING) m0205, | ||
SAFE_CAST(m0206 AS STRING) m0206, | ||
SAFE_CAST(m0207 AS STRING) m0207, | ||
SAFE_CAST(m0208 AS STRING) m0208, | ||
SAFE_CAST(m0209 AS STRING) m0209, | ||
SAFE_CAST(m0210 AS STRING) m0210, | ||
SAFE_CAST(m0211 AS STRING) m0211, | ||
SAFE_CAST(m0212 AS STRING) m0212, | ||
SAFE_CAST(m0213 AS STRING) m0213, | ||
SAFE_CAST(m0214 AS STRING) m0214, | ||
SAFE_CAST(m0215 AS STRING) m0215, | ||
SAFE_CAST(m0216 AS STRING) m0216, | ||
SAFE_CAST(m0217 AS STRING) m0217, | ||
SAFE_CAST(m0218 AS STRING) m0218, | ||
SAFE_CAST(m0219 AS STRING) m0219, | ||
SAFE_CAST(m0220 AS STRING) m0220, | ||
SAFE_CAST(m0221 AS STRING) m0221, | ||
SAFE_CAST(m0222 AS STRING) m0222, | ||
SAFE_CAST(m0301 AS STRING) m0301, | ||
SAFE_CAST(m0401 AS STRING) m0401, | ||
SAFE_CAST(m0402 AS STRING) m0402, | ||
SAFE_CAST(m0701 AS STRING) m0701 | ||
from basedosdados-staging.br_ibge_censo_demografico_staging.microdados_domicilio_2010 as t |
54 changes: 54 additions & 0 deletions
54
models/br_ibge_censo_demografico/br_ibge_censo_demografico__microdados_pessoa_1970.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{ | ||
config( | ||
alias='microdados_pessoa_1970', | ||
schema='br_ibge_censo_demografico', | ||
materialized='table', | ||
partition_by={ | ||
"field": "sigla_uf", | ||
"data_type": "string", | ||
}, | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(id_domicilio AS STRING) id_domicilio, | ||
SAFE_CAST(numero_familia AS INT64) numero_familia, | ||
SAFE_CAST(ordem AS STRING) ordem, | ||
SAFE_CAST(v001 AS STRING) v001, | ||
SAFE_CAST(v002 AS STRING) v002, | ||
SAFE_CAST(v003 AS STRING) v003, | ||
SAFE_CAST(v022 AS STRING) v022, | ||
SAFE_CAST(v023 AS STRING) v023, | ||
SAFE_CAST(v024 AS STRING) v024, | ||
SAFE_CAST(v025 AS STRING) v025, | ||
SAFE_CAST(v026 AS STRING) v026, | ||
SAFE_CAST(v027 AS INT64) v027, | ||
SAFE_CAST(v028 AS STRING) v028, | ||
SAFE_CAST(v029 AS STRING) v029, | ||
SAFE_CAST(v030 AS STRING) v030, | ||
SAFE_CAST(v031 AS STRING) v031, | ||
SAFE_CAST(v032 AS STRING) v032, | ||
SAFE_CAST(v033 AS STRING) v033, | ||
SAFE_CAST(v034 AS STRING) v034, | ||
SAFE_CAST(v035 AS STRING) v035, | ||
SAFE_CAST(v036 AS STRING) v036, | ||
SAFE_CAST(v037 AS STRING) v037, | ||
SAFE_CAST(v038 AS STRING) v038, | ||
SAFE_CAST(v039 AS STRING) v039, | ||
SAFE_CAST(v040 AS STRING) v040, | ||
SAFE_CAST(v041 AS INT64) v041, | ||
SAFE_CAST(v042 AS STRING) v042, | ||
SAFE_CAST(v043 AS STRING) v043, | ||
SAFE_CAST(v044 AS INT64) v044, | ||
SAFE_CAST(v045 AS INT64) v045, | ||
SAFE_CAST(v046 AS STRING) v046, | ||
SAFE_CAST(v047 AS STRING) v047, | ||
SAFE_CAST(v048 AS STRING) v048, | ||
SAFE_CAST(v049 AS STRING) v049, | ||
SAFE_CAST(v050 AS INT64) v050, | ||
SAFE_CAST(v051 AS STRING) v051, | ||
SAFE_CAST(v052 AS STRING) v052, | ||
SAFE_CAST(v053 AS INT64) v053, | ||
SAFE_CAST(v054 AS INT64) v054 | ||
FROM basedosdados-staging.br_ibge_censo_demografico_staging.microdados_pessoa_1970 AS t |
Oops, something went wrong.