Streaming and Change Data Capture · Lesson 2 of 5 · 16 min

Rebuilding the current state

Turn a stream of changes back into a table: the latest event per key wins, and deletes remove the row.

To get the table as it is now, keep the latest event for each key, ordered by lsn. If that latest event is a delete, the row no longer exists.

This is exactly what a sink connector or a dbt model on top of CDC does. In a warehouse you would MERGE each batch of events into the target table on order_id.

← Previous: Events, not tables