- Bootstrap the source / snapshot table
source_users
and the initial state of our scd2 tabledim_users
by running:
dbt run -m source_users dim_users
- Copy over contents of
dim_users_inc.sql
replacing contents indim_users.sql
(or just rename them). Then run:
dbt run -m dim_users
Just a heads up, I believe the "new_valid_to" CTE should be modified to pick up a single dbt_valid_to that's the minimum for a given user_id's new records
This allows for handling multiple updates to a single user_id during an incremental run as well
select d.digipass_id , min(s.dbt_valid_from) as dbt_valid_to from source_rows s join destination_rows d on s.digipass_id = d.digipass_id and s.dbt__scd_id != d.dbt__scd_id group by 1