Databricks
The Databricks template uses MERGE INTO on Delta tables, or the SCD Type 2 option of the change-data APIs in Lakeflow Declarative Pipelines.
- The MERGE form feeds one statement a union of rows that close the current version and rows that open a new one. The sketch below shows the idea.
- The AUTO CDC flow can store a target as SCD Type 2, add the start and end columns for you and track history on a chosen set of columns.
- Identity columns are an option for surrogate keys, but they restrict concurrent writes to the table. A hash of the business key and the start date avoids that.
- Facts join to the version valid at the event time with a range join on the start and end columns.