Skip to content

Commit

Permalink
Merge pull request #536 from basedosdados/staging/new_sia_incremental
Browse files Browse the repository at this point in the history
[fix-sia] producao_ambulatorial
  • Loading branch information
folhesgabriel authored Apr 8, 2024
2 parents 2daa26f + 2040619 commit 6e84923
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ with
from sia_add_municipios
)

select sia.*
select *
from sia

{% if is_incremental() %}
left join
{{ this }} as materialized
on sia.ano = materialized.ano
and sia.mes = materialized.mes
where materialized.ano is null and materialized.mes is null
where
date(cast(ano as int64), cast(mes as int64), 1)
> (select max(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
or date(cast(ano as int64), cast(mes as int64), 1)
< (select min(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
{% endif %}

0 comments on commit 6e84923

Please sign in to comment.