Skip to content

Commit

Permalink
Merge branch 'staging/migrate_1746' of https://github.com/prefeitura-…
Browse files Browse the repository at this point in the history
…rio/pipelines_rj_segovi into staging/migrate_1746
  • Loading branch information
gabriel-milan committed Dec 11, 2024
2 parents 66fceee + 1547c89 commit 65ce6b3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions queries/models/adm_central_atendimento_1746/chamado_cpf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@

-- Full refresh or new rows for incremental runs
with base_data as (
select
select
p.cpf,
c.* -- Select all columns from the chamado table
from `rj-segovi.adm_central_atendimento_1746.chamado` c
left join `rj-segovi.adm_central_atendimento_1746.chamado_pessoa` cp
on c.id_chamado = cp.id_chamado
left join `rj-segovi.adm_central_atendimento_1746.pessoa` p
on cp.id_pessoa = p.id_pessoa
where
where
c.id_chamado is not null
and cp.id_pessoa is not null
and p.cpf is not null
),
filtered_increment as (
{% if is_incremental() %}
-- Only add data not already in the target table
select *
select *
from base_data
where id_chamado not in (
select id_chamado
from {{ this }}
)
{% else %}
-- For full refreshes, include all rows
select *
select *
from base_data
{% endif %}
)
Expand Down

0 comments on commit 65ce6b3

Please sign in to comment.