Schema Evolution and Time Travel

Why tracking columns by name or position breaks

A classic Hive table records the schema by column name or position in the metastore, separately from what's actually written inside old Parquet files. That produces two different failure modes, and neither one raises an error:

✗ Position-based failure → silent corruption

schema:   (id, name, email)
          → file written with 3 columns
ALTER TABLE DROP COLUMN name
schema:   (id, email)
          → metastore says position 1 = email
old file: still physically has 3 columns

reader reads position 1 from the OLD file
  → gets the OLD "name" values
  → labels them "email"
  → wrong data, no error

✗ Name-based failure → silent data loss

ALTER TABLE RENAME COLUMN
      email TO email_address
old files still have a column
      physically named "email"

reader looks up "email_address"
  → not found in the old file
  → NULL for every historical row
  → data silently missing, no error

Nothing crashes. You find out when somebody eventually notices the numbers look wrong.

The fix: field IDs

Iceberg and Delta (through column mapping) both fix this the same way. Every column gets a permanent, unique integer field ID when it's created, and that ID is written into the Parquet file itself — with no connection to the column's current name or position.

RENAME email → email_address:
  metadata: field id=7's name changes from "email" to "email_address"
  old Parquet files: still physically say field id=7
  reader resolves by ID → "give me field 7" → works identically for files
  written before AND after the rename. No rewrite, no ambiguity.

DROP a column:
  metadata: field id=3 marked removed from the current schema
  old files: id=3's data is still physically present, simply not projected

ADD a column:
  metadata: new field id=12, with a default (or NULL for older rows)
  old files: have no field id=12 at all → reader supplies NULL/default
OperationData rewrite needed?Why
Add columnNoOld files simply lack the new field ID; resolved as NULL/default at read time
Drop columnNoNothing asks for that field ID anymore. The old bytes stay until compaction happens to rewrite the file, if ever
Rename columnNoThe field ID doesn't change. Only the ID-to-name mapping in metadata does
Reorder columnsNoLooking up columns by ID doesn't care about order
Widen a type (int → long)No, usuallyBoth formats list which widenings are safe (int→long, float→double, more decimal precision) and convert at read time
Narrow a type, or any incompatible changeYesThere's no safe way to do it in metadata alone, so the data has to be rewritten

Time travel: reading an old version

Because neither format ever changes a file it has written (see Iceberg's metadata tree, Delta's transaction log), time travel costs almost nothing to support. An "old version" is just a pointer to an older state that's still completely intact.

✓ Iceberg

SELECT * FROM events
  FOR SYSTEM_VERSION AS OF 8534680299442786500;
SELECT * FROM events
  FOR SYSTEM_TIME AS OF '2024-01-15 00:00:00';

✓ Delta Lake

SELECT * FROM events VERSION AS OF 40;
SELECT * FROM events
  TIMESTAMP AS OF '2024-01-15 00:00:00';
How "AS OF timestamp" is resolved
IcebergSearch snapshot-log in metadata.json for the newest snapshot at or before that time, then read its manifest list exactly as in the Iceberg's metadata tree part — just starting from an older pointer instead of current-snapshot-id
DeltaSearch the commit history (commitInfo timestamps) for the version that was live then, then replay from the nearest earlier checkpoint exactly as in the Delta's transaction log part — just stopping at an earlier version number

Neither format does anything at write time to "turn on" time travel. You get it for free from never changing a file once it's written. The only limit is retention: once expire_snapshots or VACUUM deletes the files an old snapshot needs, reading that point in time fails with a missing file.

Snapshot isolation for readers

Here's a guarantee that's easy to miss and matters a lot. A query that runs for 20 minutes against a table being written to the whole time still sees one consistent snapshot from start to finish — the one it picked up when it began. It never sees a mix of old and new data as commits land underneath it.

A 20-minute query is isolated from everything committed while it runs
A 20-minute query is isolated from everything committed while it runs

This comes straight from the same rule as everything else here. The query locks onto one version when it starts, and no file that a live snapshot needs gets deleted underneath it. So a long reader is automatically protected from concurrent writers with no lock, no version-management engine, and no coordination at all. It's a side effect of "never change anything, just add new pointers."

The Invariants

  • Guarantees: Adding, dropping, renaming, reordering, or safely widening a column never requires rewriting old data. A query locked to a version sees one consistent view for as long as it runs, no matter what else commits. Time travel works to any point inside the retention window, with nothing to enable at write time.
  • Does not guarantee: Time travel doesn't go back forever. It stops at your expire_snapshots / VACUUM retention, and once those files are deleted that history is gone — not slow to reach, gone. And the schema safety only applies if the feature is on: a Delta table created without column mapping doesn't get it. Iceberg does by default, because it's part of the format.