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-incremental] br_mg_belohorizonte_smfa_iptu #286

Merged
merged 3 commits into from
Sep 12, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ config(alias='dicionario', schema='br_mg_belohorizonte_smfa_iptu') }}


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-dev.br_mg_belohorizonte_smfa_iptu_staging.dicionario AS t
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{{ config(
alias='iptu',
schema='br_mg_belohorizonte_smfa_iptu',
materialized='incremental',
materialized='table',
partition_by={
"field": "mes",
"field": "ano",
"data_type": "int64",
"granularity": "month"},
"range": {
"start": 2022,
"end": 2023,
"interval": 1}
},
cluster_by=['tipo_construtivo', 'tipo_ocupacao', 'tipologia'],
labels = {'project_id' : 'basedosdados-dev'}
) }}

WITH iptu AS (
)}}
SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
Expand All @@ -37,12 +39,8 @@ SAFE_CAST(indicador_agua AS BOOL) indicador_agua,
SAFE.ST_GEOGFROMTEXT(poligono) poligono,
SAFE_CAST(fracao_ideal AS FLOAT64) fracao_ideal,
SAFE_CAST(area_terreno AS FLOAT64) area_terreno,
SAFE_CAST(area_construida AS FLOAT64) area_construida,
FROM basedosdados-dev.br_mg_belohorizonte_smfa_iptu_staging.iptu AS t)
SELECT * FROM iptu

{% if is_incremental() %}

WHERE ano > (SELECT max(ano) FROM {{ this }}) and mes > (SELECT max(mes) FROM {{ this }})

{% endif %}
SAFE_CAST(area_construida AS FLOAT64) area_construida
FROM basedosdados-dev.br_mg_belohorizonte_smfa_iptu_staging.iptu AS t
-- {% if is_incremental() %}
-- WHERE CONCAT(ano,mes) > (SELECT MAX(CONCAT(ano,mes)) FROM {{ this }} )
-- {% endif %}
22 changes: 20 additions & 2 deletions models/br_mg_belohorizonte_smfa_iptu/schema.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
version: 2

models:
- name: br_mg_belohorizonte_smfa_iptu_iptu
- name: br_mg_belohorizonte_smfa_iptu__iptu
description: Dados referente ao cadastro do IPTU na cidade de Belo Horizonte
columns:
- name: ano
description: Ano
- name: mes
description: Mês
- name: indice_cadastral
description: Os imóveis, para inscrição no Cadastro Imobiliário, foram codificados através de sua associação a um código alfanumérico denominado índice cadastral, composto de 15 dígitos.
- name: lote
Expand Down Expand Up @@ -51,4 +55,18 @@ models:
- name: area_terreno
description: Área do terreno
- name: area_construida
description: Área construida
description: Área construida

- name: br_mg_belohorizonte_smfa_iptu__iptu_dicionario
description: "Dicionário de dados da tabela de IPTU da cidade de Belo Horizonte"
columns:
- name: id_coluna
description: ID da coluna
- name: nome_coluna
description: Nome da coluna
- name: chave
description: Chave
- name: cobertura_temporal
description: Cobertura temporal
- name: valor
description: Valor