billing-service
local runtimesource stays localdbt CDC14 passed, 0 failedWorkspace ready
models/staging/invoices.sql
with source as (
select *
from {{ source('billing', 'invoice_events') }}
),
deduped as (
select
invoice_id,
customer_id,
event_type,
event_timestamp,
row_number() over (
partition by invoice_id
order by event_timestamp desc
) as latest_record
from source
),
cdc_ready as (
select
invoice_id,
customer_id,
event_type,
event_timestamp,
current_timestamp as processed_at
from deduped
where latest_record = 1
)
select * from cdc_readyTerminal
$ dbt compile Compilation completed successfully $ dbt test --select invoices 14 passed, 0 failed, 0 warnings