Iceberg DELETE Doesn't Delete PHI. Snowflake and BigQuery Don't Either.
An Iceberg DELETE doesn't erase PHI, and Snowflake and BigQuery keep it through fail-safe. Purge order, deletion SLAs and training manifests that rebuild.
Key takeaways
- An Iceberg DELETE only writes delete files. PHI stays on disk until you rewrite data files, expire snapshots and clean up orphans, in that order.
- Your real deletion date includes fail-safe: 8 to 97 days on a permanent Snowflake table and 9 to 14 on BigQuery, and neither lets you purge fail-safe early.
- Store each training set as a manifest of patient id, resource id and versionId with an exclusion list, so models rebuild minus revoked patients without pinned snapshots.
I don't trust a delete I can't count.
In Apache Iceberg, DELETE doesn't delete data. It writes a delete file or a deletion vector and commits a new snapshot. The old data file stays on disk, and time travel can still read it, until no snapshot references it. Snowflake and BigQuery behave the same way, except the vendor controls part of the timeline. If you keep PHI in a lakehouse, a deleted patient is gone only after you rewrite the data files, expire the snapshots and wait out fail-safe. Then you have to prove it.
I've written about getting HL7v2 into Snowflake and into Google Cloud. Getting a patient back out is the harder half. Most lakehouse erasure writing is about GDPR. It doesn't cover a revoked patient sitting in last quarter's training snapshot.
Clinical platforms have two jobs that pull against each other. Data has to be gone when it should be gone. Models trained on that data have to be reproducible. Most teams get reproducibility from time travel or a pinned snapshot, and that quietly breaks deletion. My position: stop using time travel as your reproducibility mechanism. Store training sets as manifests of resource versions with an exclusion list, and let snapshots expire. The rest of this post is the plumbing that makes that work.
What triggers a deletion, and what each one costs you
Each cause hits the data differently, and each one needs something in place before the request arrives.
- Entered-in-error. FHIR R4 gives many clinical resources an
entered-in-errorstatus. The record was never true. Purge it. A status filter in your views doesn't reach a training export or an old snapshot. - Patient merges. FHIR represents a merge with
Patient.link(replaced-by/replaces). The losing record's rows still exist under the old id, and derived tables like OMOP may carry it under yet another id. The purge job has to resolve every id the patient ever had. - Consent revocation, 42 CFR Part 2 records and state health-data laws such as Washington's My Health My Data Act. The patient goes on an exclusion list that every rebuild reads, and the purge has to reach every tier below.
- The end of a research data-use agreement. Every row that came in under that DUA has to go. You can only scope that delete if you tagged each row with its DUA at ingest. Add the column now, not when the agreement ends.
Counsel decides which of these require physical deletion and by when. Engineering's job is to make the date achievable and provable. You also have to know the delete happened. A bulk FHIR export doesn't hand you deletes, so you often have to detect them yourself before any of this starts.
Where deleted data still lives after an Iceberg DELETE
Start with an inventory. Every row in this table still holds data your DELETE already "removed."
| Location | Who controls expiry | How long it can survive | How to check |
|---|---|---|---|
| Iceberg snapshots | Your expireSnapshots job | Until the job runs | snapshots metadata table |
| Delete files, deletion vectors | Your compaction job | Until data files are rewritten | delete_files metadata table |
| Iceberg tags and branches | Ref retention you set | As long as the ref lives | refs metadata table |
| Old metadata, orphan files | Orphan cleanup | Until cleanup runs (3-day minimum interval) | File listing vs. metadata |
| Snowflake Time Travel + Fail-safe | Snowflake, partly you | 8 to 97 days | Retention setting per table |
| BigQuery time travel + fail-safe | Google, partly you | 9 to 14 days | INFORMATION_SCHEMA.TABLE_STORAGE |
| Clones and table snapshots | Whoever made them | Until dropped | Your inventory |
| FHIR version history | You | Until purged | Row check by patient |
| Derived copies: OMOP, stored LLM outputs, embeddings | You | Until purged | Row check by patient |
| Exported training parquet | Nobody | Forever | Register it or ban it |
A few details the table can't hold:
- Iceberg won't delete a data file while any snapshot usable for time travel or rollback still references it. The spec has deletion vectors replace position delete files in v3, but equality deletes still exist. Deletion vectors reduce file sprawl. They don't erase anything.
- A tag on "the snapshot we trained v3 on" keeps that snapshot alive, along with every patient in it. Set retention on every ref explicitly. Don't trust your catalog's default.
- Iceberg keeps old metadata JSON by default (
write.metadata.delete-after-commit.enabled=false). In the docs' example withprevious-versions-max=10, 100 commits leave 10 tracked metadata files and 90 orphans. - Snowflake Fail-safe starts when Time Travel ends, and a long-running Time Travel query pushes that start back.
- A deleted BigQuery table keeps the time travel window in effect when it was deleted. Shortening the window afterward doesn't help. Google points to table snapshots for retention beyond the window, so a table snapshot outlives your deletion by design.
- Embeddings of notes need their own purge from the index. Deleting the source row doesn't touch them.
Iceberg snapshot expiry only works after compaction
Iceberg's maintenance docs list rewriteDataFiles and rewritePositionDeletes under "Optional Maintenance." For erasure they are mandatory. Skip them and the deleted rows stay physically present in data files that live snapshots still reference.
The order is rewrite, then expire, then clean up orphans:
-- 1. Logical delete: writes delete files / deletion vectors only
DELETE FROM lake.clinical.observation
WHERE patient_id IN (SELECT patient_id FROM lake.ops.purge_queue WHERE status = 'pending');
-- 2. Rewrite data files carrying deletes; drop dangling delete files
CALL lake.system.rewrite_data_files(table => 'clinical.observation',
options => map('remove-dangling-deletes', 'true'));
CALL lake.system.rewrite_position_delete_files(table => 'clinical.observation');
-- 3. Expire every snapshot committed before the rewrite
CALL lake.system.expire_snapshots(table => 'clinical.observation',
older_than => TIMESTAMP '${rewrite_commit_ts}', retain_last => 1);
-- 4. Orphans last, never below the 3-day default interval
CALL lake.system.remove_orphan_files(table => 'clinical.observation');
Step 2 needs a check. Don't assume the rewrite touched every file the purge hit. Look up how your Iceberg version selects files for rewrite, set the options so purge-touched files are included, and confirm with the reconciliation below, not the exit code.
Step 3 can be blocked. Any tag or branch holding an old snapshot keeps it from expiring. Ref retention belongs in the purge job, not on a wiki page.
Step 4 has two traps. The docs warn that an interval shorter than the 3-day default can delete files from writes still in progress, which corrupts the table. Orphan cleanup also compares paths as strings, so if your storage paths have ever changed, it can delete live data. Run it, but never tune it aggressively to hit a deadline.
Snowflake and BigQuery: how long deleted PHI is kept
One global "we delete within N days" promise doesn't work, because each platform has a different floor:
- Snowflake permanent tables: Time Travel retention (1 day standard, up to 90 on Enterprise) plus 7 days of Fail-safe you can't configure. That's 8 days at the standard and 97 if someone raised retention to 90.
- BigQuery: a 2 to 7 day window, 7 by default, plus 7 days of fail-safe you can't modify. That's 9 to 14 days, never fewer than 9. In Google's own example, data deleted on day 0 is unrecoverable on day 15.
- Iceberg: your expiry schedule plus ref retention plus the orphan interval. No vendor floor, and no ceiling either if the jobs never run.
Neither Snowflake nor BigQuery lets you purge fail-safe early. Your legal "gone" date has to include it.
A plain CREATE TABLE in Snowflake gives you a permanent table. If you landed HL7v2 that way, Fail-safe is part of your deletion timeline whether you planned for it or not. Transient and temporary tables have their own rules. Read the current docs before you design around them.
Set the SLA per cause. Entered-in-error, a merge, a revocation, a Part 2 record, a state-law request and the end of a DUA can each carry a different deadline. Get each date from counsel. My HIPAA consent piece covers what engineers need from that conversation. Then work backward. If a cause's deadline is shorter than the longest storage path for the tables holding that data, shorten the path. Don't promise a date the platform can't hit.
How to verify deleted data is really gone
A purge job that exits 0 proves nothing. After the expected gone date, run a reconciliation and alert on anything above zero. The checks run on different engines, so the alerting job runs each one and sums the results:
-- Iceberg (Spark SQL), per table in the inventory
SELECT count(*) AS survivors
FROM lake.clinical.observation o JOIN lake.ops.exclusions x USING (patient_id);
SELECT count(*) AS old_snapshots
FROM lake.clinical.observation.snapshots WHERE committed_at < :rewrite_committed_at;
SELECT count(*) AS live_delete_files FROM lake.clinical.observation.delete_files;
-- BigQuery: retained bytes should drain to 0 after the window + fail-safe
SELECT table_name, time_travel_physical_bytes + fail_safe_physical_bytes AS retained
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE table_schema = 'clinical_raw';
The row check proves the logical delete. The snapshot check proves expiry. A live delete file after compaction means some data file still carries hidden rows. Confirm those metadata tables exist in your Iceberg version before you wire up alerts. Run the row check against clones, the version history store, OMOP tables and feature tables too.
The BigQuery check is coarse. It counts bytes, not patients. It's still worth running because a scheduled job can read it. On physical storage billing, time travel and fail-safe bytes are billed. On logical billing, the default, they aren't billed separately, so confirm the columns populate for your datasets. And budget for this: BigQuery versions whole storage blocks, so a one-cell delete can push far more than one row into time travel.
Exported parquet won't show up in any of these queries unless you register it as an external table. Register it or ban the export.
Reproducible ML training sets without time travel
A snapshot pinned forever keeps every revoked patient in it for as long as the pin lasts.
Make a training set a manifest, not a snapshot. Record the exact FHIR resources that went in, keyed by patient id, resource type, resource id and versionId, plus the split. Keep an exclusion list next to it. A rebuild is the manifest minus the exclusions:
SELECT m.resource_type, m.resource_id, m.version_id, m.split
FROM ml.training_manifest m
LEFT JOIN ops.exclusions x ON x.patient_id = m.patient_id
WHERE m.model_id = 'readmit-v7' AND x.patient_id IS NULL;
Rebuilding by versionId needs a store that keeps old versions, such as a FHIR server's _history or an append-only table of resource versions. That store is PHI. It goes on the inventory and into reconciliation, and revoked patients get purged from it like everywhere else. You can only rebuild from versions you're still allowed to hold.
For clinical data, "reproducible" means reproducible minus the people who left. It doesn't mean bit-identical forever. The manifest still shows what went in, in which split and at which version. Compare the rebuilt model against the old one on a frozen eval set, the replay approach from detecting model drift in clinical AI. If metrics move after a revocation rebuild, record that next to the model version.
Whether every revocation triggers a rebuild is a policy decision per cause. Track the count either way.
Retention tiers for PHI in a lakehouse
Not every table needs the same retention. I split it three ways:
- Raw PHI (HL7v2 landing, FHIR resources, staging, version history). Use the shortest retention you can live with: the 1-day Time Travel standard on Snowflake, never raised; 2 days on BigQuery; aggressive Iceberg expiry. Deletes land here, so this tier gets the shortest path to gone. Raising Time Travel on a raw PHI table to 90 days adds 89 days to every deletion.
- De-identified feature tables. Longer retention is fine if the de-identification holds up. Measure recall per identifier, not one overall number. Key rows on a pseudonymous id and keep the
patient_id-to-pseudonym mapping in the raw tier. On revocation, resolve the pseudonym, add it to the exclusion list, delete the matching feature rows, and only then purge the mapping with the rest of the raw data. - Legal hold. The only path that keeps a snapshot past its SLA. It needs two human signatures, one from legal or compliance. It also needs a named reason, an expiry date and an entry in the reconciliation job, so a held snapshot shows up as an expected survivor instead of a silent one.
Never pin a snapshot indefinitely. A hold with no end date is a forgotten copy of PHI with paperwork attached. Holds should expire by default and get renewed on purpose.
Test your time-to-purge with a deletion drill
You don't know your time-to-purge until you measure it. Create a synthetic patient. Push it through ingestion, transforms, a feature table, an OMOP load, a clone and a training export. Then revoke it and start a clock.
Record when each location in the inventory table reaches zero. The slowest location is your real SLA, whatever the policy document says.
Each drill produces three numbers. Track them per cause:
- Time-to-purge, from the request to the moment the last location reaches zero.
- Surviving rows after expiry. The target is zero. A documented legal hold is the only acceptable exception.
- Models rebuilt after a revocation.
Run the drill again whenever someone adds a table, changes retention or creates a tag. A deletion process you've never timed is a guess.
Questions people ask
Does deleting a row in Apache Iceberg remove the data?
No. A DELETE writes a delete file or deletion vector and commits a new snapshot, and time travel can still read the old data file. The rows are physically gone only after you rewrite the data files, expire the snapshots and clean up orphan files.
Do Iceberg v3 deletion vectors erase deleted data?
No. Deletion vectors replace position delete files and reduce file sprawl, but the data bytes survive until the data files are rewritten and the snapshots expire. Equality deletes also still exist in v3.
How long does deleted data stay in Snowflake and BigQuery?
On permanent Snowflake tables, deleted data stays for the Time Travel retention (1 day as standard, up to 90 on Enterprise) plus 7 days of Fail-safe. BigQuery keeps it for a 2 to 7 day window plus 7 days of fail-safe. Neither platform lets you purge fail-safe early.
How do you keep ML models reproducible when patient data must be deleted?
Store each training set as a manifest of patient id, resource type, resource id and versionId with an exclusion list, and rebuild from the manifest minus the exclusions. Don't pin snapshots forever, because a pinned snapshot keeps every revoked patient in it.