Snapshots - set dbt_valid_from to created_at instead of updated_at for initial snapshot?

I’m only now adding dbt snapshots for a source table which has existed for years. My source table has both created_at and updated_at timestamps, and I’ve configured the snapshot with the timestamp strategy using the updated_at column.

Now obviously dbt sets dbt_valid_from to the record’s updated_at value each time it creates a snapshot, and of course that makes perfect sense.

However I’m struggling with the initial snapshot records. The source records are years old and have been updated after creation, but before standing up dbt. For example…

Source Record

id: 1000
created_at: 2022-02-02
updated_at: 2023-03-03

Actual Initial Snapshot

dbt_valid_from: 2023-03-03

Expected Initial Snapshot

dbt_valid_from: 2022-02-02

Is there any way to configure the snapshot to use created_at for dbt_valid_from only for the initial snapshot?

If not, how do I best select the proper snapshot for a given moment in time where the source record existed before min(dbt_valid_from)?

1 Like