Amazon Redshift
Stage a Redshift merge, pick one row per account revision and verify that unrelated target duplicates stay visible.
- Stage source rows
- Account A has revisions 22 and 23.
- Approve a winner
- Choose revision 23 and flag unresolvable ties.
- Verify target
- Account A updates, account B inserts and unrelated duplicates remain visible.
An inbound file has two revisions for one CRM account and a new record for another. If both revisions are merged directly, one target row can match twice. In Amazon Redshift, validate a staging table before applying updates to the reporting copy.
Choose one staged row per target business key
Load the file into a temporary staging table, then build a merge input with a deterministic winner per key. Use the latest verified source revision. Hold tied revisions with conflicting values for review. Check the target’s key counts as well. Use a matching distribution key for the staging and target tables where appropriate for the workload, and verify the query plan.
In the example, account A appears as revision 22 and revision 23. Keep revision 23 for the upsert. Account B is new and has one row. Redshift’s simplified REMOVE DUPLICATES form requires compatible table shape and removes matched duplicates on the destination. It does not repair unrelated duplicate destination keys, so scope any cleanup separately.
Approve the stage before applying the merge
| Check | Expected result | Decision |
|---|---|---|
| Input staging group | One candidate per account for the merge. | Keep revision 23 for A and reject an unresolved conflicting tie. |
| Test merge | A updates to revision 23 and B is inserted once. | Read both target rows and confirm the expected amounts or statuses. |
| Destination uniqueness check | Unrelated duplicate keys are visible as separate findings. | Keep a list of duplicates that did not match this batch for steward review. |
Confirm one more run leaves the two intended records at the same values and keys. Use the integration guide to decide which revision is authoritative before running a bulk retry.