Skip to content

Commit

Permalink
Merge pull request #294 from basedosdados/fix_br_bcb_estban
Browse files Browse the repository at this point in the history
[fix-dbt] `br_rf_cafir`
  • Loading branch information
folhesgabriel authored Sep 15, 2023
2 parents f948146 + b97a3bb commit c76e976
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions models/br_rf_cafir/br_rf_cafir__imoveis_rurais.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ fixed_names as (
from lower_munis
LEFT JOIN (SELECT LOWER(REGEXP_REPLACE(NORMALIZE(nome, NFD), r"\pM", '')) nome_municipio, id_municipio, sigla_uf as sigla_uf1 FROM basedosdados.br_bd_diretorios_brasil.
municipio) as mun
ON lower_munis.nome_mun = mun.nome_municipio AND lower_munis.sigla_uf = mun.sigla_uf1)

SELECT
ON lower_munis.nome_mun = mun.nome_municipio AND lower_munis.sigla_uf = mun.sigla_uf1),
final as (SELECT
SAFE_CAST(data as DATE) data_referencia,
SAFE_CAST(FORMAT_DATE('%Y-%m-%d', safe.PARSE_DATE('%Y%m%d', data_inscricao))as DATE) AS data_inscricao,
SAFE_CAST(id_imovel_receita_federal as STRING) id_imovel_receita_federal,
Expand All @@ -94,7 +93,9 @@ SELECT
SAFE_CAST(sigla_uf as STRING) sigla_uf,
--- esta coluna não é identifica no dicionário nem nomeada nos arquivos
--- SAFE_CAST(LOWER(status_rever) as STRING) coluna_nao_identificada,
FROM fixed_names AS t
FROM fixed_names AS t)
select * from
final
{% if is_incremental() %}
WHERE data_referencia > (SELECT MAX(data_referencia) FROM {{ this }} )
{% endif %}

0 comments on commit c76e976

Please sign in to comment.