Implement Delta Lake MERGE for upsert-based SCD Type 1 with WHEN NOT MATCHED BY SOURCE

domain: delta.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Stage incoming records in a source DataFrame or temporary view with a business key and an updated_at timestamp
  2. Write a MERGE INTO statement that matches on the business key and updates target columns WHEN MATCHED AND source.updated_at > target.updated_at
  3. Add a WHEN NOT MATCHED BY TARGET THEN INSERT clause to insert net-new rows from the source
  4. Add WHEN NOT MATCHED BY SOURCE THEN DELETE to remove target rows that are absent in the source batch, representing hard deletes
  5. Run DESCRIBE HISTORY after the merge to confirm the operationMetrics show the expected counts for rowsUpdated, rowsInserted, and rowsDeleted

Known gotchas

Related routes

Perform a Delta Lake MERGE upsert with WHEN NOT MATCHED BY SOURCE to handle deletes from a CDC source
docs.delta.io · 5 steps · unrated
Enable Delta Lake row tracking for stable row IDs across MERGE and UPDATE
data-engineering · 5 steps · unrated
Enable Delta Lake schema enforcement and safely perform schema evolution with mergeSchema
docs.delta.io · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans