A merge operation compares target records with a staging dataset and conditionally inserts, updates, or deletes rows. It extends append-only ingestion for reconciliation, late-arriving data, and slowly changing dimensions. section 6.3.1 section 6.4.1
Use merge operations to:
- Match source and target records on a key, then update matched rows. section 6.4.1
- Insert source records without a target match. section 6.4.1
- Handle row-level changes through copy-on-write or merge-on-read strategies, balancing read performance against write amplification and latency. section 6.3.1
Spark SQL upsert
MERGE INTO my_catalog.db.my_table t USING my_catalog.db.staging_table s ON t.id = s.id WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT * section 6.4.1
Figure 6.10 Merge transactions allow you to compare records to a staging dataset and conditionally insert, update, and delete records.
Visualizes how a merge transaction compares records with staging data and applies conditional inserts, updates, and deletes. section 6.3.1
