Skip to content

Commit

Permalink
Merge pull request #286 from basedosdados/staging/br_mg_smfa
Browse files Browse the repository at this point in the history
[dbt-incremental] br_mg_belohorizonte_smfa_iptu
  • Loading branch information
tricktx authored Sep 12, 2023
2 parents 4bec9fa + 22e837e commit bed297b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
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

0 comments on commit bed297b

Please sign in to comment.