Replay an import using a stable coalesce key
Replay an asset delivery and account for inserted, updated, unchanged and rejected rows.
Replay an import using a stable coalesce key
Work through the decision
A supplier sends the same three devices twice. A test import creates six records because the display names changed. What should an administrator decide before running another transform?
Check your reasoning
Stage the incoming rows in an import set. Map a durable source identifier to a target field and configure coalescing so an existing match is updated. Define how to handle blank or ambiguous keys and verify counts in a test instance. Transform history distinguishes inserts, updates and rejected rows.
Compare the choices
- Import set table
- Land incoming rows in a staging area so source values can be inspected before conversion into target records.
- Transform map
- Define how staged fields map to target fields and how values should be converted. Verify types and reference resolution.
- Coalesce field
- Use a stable identifying value, or a supported combination of values, to decide whether to match an existing target record. No match normally leads to insertion under the configured transform.
- Transform history
- Review row-level outcomes and counts after transformation. Reconcile updates and inserts against source expectations before approving the load.
Interpret an unexpected count
A source has keys D7, D8 and a blank. The target already contains D7. Under a policy that rejects blank keys, expect one update, one insert and one rejection. Replaying only the two valid rows should leave the target count unchanged.
Practice the guide skills
- Stage two deliveries of an asset feed. Map fields, coalesce on a stable key, reconcile inserted and updated rows and isolate a row without an acceptable key. Watch 2:14:41
Official objectives for this lesson
Lab · Reconcile two deliveries of an asset feed
A transform should match assets by a stable external ID. Predict the insert and update counts before running this local Python 3 model. The feed owner requires missing keys to be rejected explicitly.
assets = {"A17": "Design"}
delivery = [("A17", "Operations"), ("B29", "Sales"), ("", "Finance")]
def reconcile(rows):
counts = dict(inserted=0, updated=0, unchanged=0, rejected=0)
for external_id, team in rows:
if not external_id:
counts["rejected"] += 1
elif external_id not in assets:
assets[external_id] = team
counts["inserted"] += 1
elif assets[external_id] != team:
assets[external_id] = team
counts["updated"] += 1
else:
counts["unchanged"] += 1
return ", ".join(f"{key}={value}" for key, value in counts.items())
for batch in ("first", "replay"):
print(batch, reconcile(delivery))
print("target IDs", ", ".join(sorted(assets)))
Check the result
first inserted=1, updated=1, unchanged=0, rejected=1 replay inserted=0, updated=0, unchanged=2, rejected=1 target IDs A17, B29
Supply a verified new key for the rejected row and rerun. Exactly one extra asset should exist after both passes. In an instance, stage the source, map its ID to the coalescing target field, enforce the missing-key policy and compare transform history with the target records.
Related lesson · Keep the right rows in a join
Replay an import using a stable coalesce key quiz
Answer 3 questions. Check each answer for an explanation.
Worked example · Replay an import using a stable coalesce key