Course contents 09 / 35

09 / 35 · Files and Tables

Table formats and snapshots

Use Iceberg to publish a complete file set, recover a concurrent append and preserve field identity across a rename.

A sales table contains files A and B with 600 and 400 rows. Compaction writes C with the same 1000 rows. All three files can exist at once. A reader that lists a storage prefix and opens every file sees the old and new copies together. A table needs a definition of membership independent of file existence.

Resolve a table name to one snapshot#

A catalog resolves a table name to its current metadata. In Iceberg, that metadata records the schema, partition specifications and snapshots. A snapshot identifies a table state. In Iceberg format versions 1–3, the snapshot references a manifest list, and the listed manifests track data files and, where supported, delete files. File-level partition values and metrics let the planner avoid opening files that cannot match. The reader chooses one snapshot, follows its metadata and uses that file set for the query. The file format then decodes individual files. (Apache Iceberg, Table Spec)

Use S10, S11 and S12 as labels for toy snapshots. They are chronological names in this example, independent of how Iceberg assigns snapshot IDs. S10 contains A and B and gives 1000 rows. A writer can create candidate file C without changing S10. An already running reader of S10 can continue reading A and B while they remain retained.

Commit a change against the state it read#

A writer prepares data and metadata before publishing them. An Iceberg metastore catalog can commit by checking that the current metadata pointer still equals the writer’s base pointer and atomically swapping it to the new pointer. The conditional update is the publication boundary. A successful upload of C is only a preparation step. (Apache Iceberg, Optimistic Concurrency and Metastore Tables)

Suppose a second writer appends file D with 50 new rows and commits S11 before compaction publishes. S11 contains A, B and D. The compaction writer’s attempted swap from S10 now fails. It reloads the current state, verifies that A and B are still live and that the rewrite’s required validation passes, then retries with a new proposal. S12 contains C and D. It also has 1050 rows. If another update had removed A, compaction could not blindly reuse the stale plan.

Figure

Compaction retains the concurrent append

Compaction retains the concurrent appendS11 adds D. After checking its new base, S12 replaces A and B with C, retaining D and all 1050 rows.S10A, B1000 rowsS11A, B, D1050 rowsS12C, D1050 rows
S11 adds D. After checking its new base, S12 replaces A and B with C, retaining D and all 1050 rows.

The check protects concurrent changes. An unconditional pointer update to just C would lose D. A prefix listing of A, B, C and D would count 600+400+1000+50=2050600+400+1000+50=2050 rows instead of 1050. The snapshot decides which files to use, even when storage correctly lists every object.

A failed commit can leave unreferenced files. Conversely, a file removed from the newest snapshot can remain needed by a retained snapshot. Expiring snapshots and cleaning up orphan files are separate maintenance steps, with a retention window that accounts for readers and running writes. The guarantee described here is for one table. An atomic metadata swap for one table does not coordinate a write to several tables or to an external service. (Apache Iceberg, Table Spec and Maintenance)

Keep field identity through a rename#

Suppose the field amount_cents has ID 17 and we rename it to net_cents. Under Iceberg schema evolution, the renamed field keeps its ID, so readers can map old files to the renamed field. A later new field with the old name needs a new ID. Otherwise a name reuse could recover old values under the wrong meaning. Renaming changes a name, and a change in units or business definition still requires an explicit data migration or new field. Iceberg can also retain old partition specifications for old files and use a newer layout for later writes. The planner interprets each according to its recorded specification. (Apache Iceberg 1.10.0, Evolution)

The metadata representation depends on the table format. Delta Lake describes an ordered transaction log of file and metadata actions with checkpoints. Hudi exposes a timeline of actions with requested, inflight and completed states. All three examples make readers resolve committed metadata before selecting data files, while their publication and concurrency protocols differ. (Armbrust et al., §3, Apache Hudi, Timeline)

Next#

A snapshot determines which files workers should read. It leaves open how to distribute filters, joins and aggregations once the data is spread across nodes. Distributed SQL and MPP follows that execution path.

References#

  1. Apache Iceberg. Table Spec, Evolution and Maintenance. Metadata pointers, snapshots, commit validation, field IDs and retention.
  2. Michael Armbrust et al. Delta Lake: High-Performance ACID Table Storage over Cloud Object Stores. PVLDB 13(12), 2020, §3. Describes the log, checkpoints and file membership.
  3. Apache Hudi. Timeline. Describes the action states and how completed actions become visible on the timeline.