Skip to main content
TutorialApplies to: Unified engine deployments
Compare a version-guarded merge with an additive update when a batch is repeated. Reapplying the same source batch can leave the same final rows when actions use stable values and compare source and target versions. That does not make every MERGE repeat-safe. An additive assignment applies its arithmetic again. Final-row stability is also different from retrying a submission whose commit outcome is unknown. Use the existing operation identity to inspect or retry that original submission.

Before you start

You need a writable Iceberg catalog with namespace creation, table creation, and MERGE support. These examples create format-v2 tables in a private namespace. They use inline data and do not need an external sample dataset. Choose an unused namespace. The examples use learn_merge_06. Replace it everywhere if it already exists. In Workbench, select your writable catalog before running any SQL. Keep that catalog selected throughout the lesson. Opening an example does not execute it.

Set up the namespace

Run this setup once:
Each example creates a separate table. Run an example’s setup once. To start it again, remove only that example’s table first, using the cleanup section. Scripts execute as separate operations; they are not a multi-statement transaction.

1. Reapply a versioned batch without changing final rows

Start with these target rows:
Apply the incoming source below:
Check all rows:
Run only the MERGE and SELECT again. After two applications, expect: Run the MERGE statement a second time without rerunning setup. The final rows should be identical.

2. Observe an additive update applying twice

Start with these target rows:
Apply the incoming source below:
Check all rows:
After the first MERGE: Run only the MERGE and SELECT again. After two applications, expect: Run the MERGE statement twice without rerunning setup. The second application adds the incoming amount again.

Change one thing

Start the relevant example again from its original target rows. Drop only that example table, rerun its CREATE TABLE and INSERT statements, then apply the changed MERGE. Keep the lesson namespace. In the additive example, change the incoming amount from 25 to 10. Customer 2 should have balance 210 after one run and 220 after two runs.

Check the result

Compare every row and field with the expected tables, including unchanged customers and the number of copies of each key. A Succeeded status alone is not the result check. Wait for confirmed publication before reading the target.

Clean up

Remove only the private tables created by this lesson:

Continue

Apply customer change events or review the MERGE SQL reference.
Last modified on November 4, 2026