Skip to content

Commit

Permalink
feat: insert new incremental materilialization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
folhesgabriel committed Apr 3, 2024
1 parent d9124b2 commit 2c53dfd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ select
safe_cast(pa_fler as string) flag_erro_corpo_apac,
from sia_add_municipios
{% if is_incremental() %}
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 }})
left join
{{ this }} as materialized
on sia_add_municipios.ano = materialized.ano
and sia_add_municipios.mes = materialized.mes
where materialized.ano is null and materialized.mes is null
{% endif %}

0 comments on commit 2c53dfd

Please sign in to comment.