07 · Tables A→ZH · Edit data over time
Bulk corrections safely
The validate → fix → re-validate loop for correcting data at scale without surprises.
When you're fixing data at scale - typos in a constrained column, bad values, a botched import - do it as a loop: find the problems, fix them in one atomic batch, confirm clean.
The loop
- Find - run the validators:
validate_constraints(table) # PK / NOT NULL / CHECK violations, with sample rows validate_domain_values(table) # domain mismatches + typo suggestions - Fix - apply corrections in one
merge_rowsbatch (use the typo suggestions, e.g."actve" → "active"). One batch = one version. - Re-validate - run both validators again; repeat until zero.
- Confirm -
profile_tablefor a final sanity check, andget_table_historyto see the expected row metrics.
Why this is safe
Good to know
Validation reports, it doesn't auto-fix - so you review
before writing. The fix
merge_rows is atomic: if any corrected row still
violates a constraint, the whole batch is rejected and nothing half-lands. And the
write is a Delta version, so a wrong correction is reversible.Tips
- Batch, don't drip - one large
merge_rowsbeats thousands of single-row writes (fewer versions, less compaction churn). - Validate after every bulk mutation, not just corrections - make
validate_constraints+validate_domain_valuesa habit. - For reference-domain orphans (a deleted source value),
validate_domain_valuesis what surfaces them.