﻿# Apache Iceberg: snapshot identity and schema evolution in ML data

Understand Iceberg field IDs, historical schema selection and snapshot expiration when reconstructing a model dataset after table changes.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/data-guide-iceberg-snapshot-schema-evolution/
Language: en

## Column identity survives a rename

Apache Iceberg supports schema evolution using identifiers assigned to columns. This differs from relying only on a column's position or visible name. Renaming or reordering a field need not make old values become values of a different field.

For a feature-preparation pipeline, this distinction matters when a table evolves between model releases. A script selecting columns by their current names still needs an explicit output contract. Correct storage-level identity does not ensure that an old feature-building script selects the intended new columns.

## Record the snapshot behind a dataset

Iceberg snapshots identify table states that can be used for historical reads. Preserve the table identifier and snapshot reference used to build the training examples. The current table state is a moving target when new writes continue.

If labels are corrected later, a rerun on the latest table may produce a different evaluation set despite using the same query text. A recorded snapshot helps explain whether a score changed because of the model or because the input records were revised.

## Inspect which schema a query selects

The current Spark query documentation distinguishes snapshot- or timestamp-selected reads, which use the snapshot schema, from branch queries, which use the table schema. Tag-based historical reads use the referenced snapshot's schema. These differences matter when columns were added after the selected records were written.

An illustrative review compares the projected field names, types and null behavior before passing data to a model. A query can successfully return historical rows under a schema different from the one an experiment author expected. Query success alone does not reveal that mismatch.

## Partition changes do not rewrite the past immediately

Iceberg also supports partition evolution. Older files can remain under an earlier partition specification while newer files use a new layout. The table metadata coordinates those layouts rather than requiring a consumer to interpret storage directories as one fixed partition scheme.

Avoid rebuilding a dataset by scanning arbitrary object-store paths and guessing partition meaning from folder names. Use the intended table interface and retain the query conditions. Otherwise a pipeline may bypass information needed to interpret the table correctly.

## Retain the state needed for reconstruction

Snapshot expiration removes historical snapshots from time-travel availability and allows unneeded files to be cleaned up. An experiment record containing a snapshot identifier is therefore not an independent archive of every referenced file.

Align snapshot retention with the required research horizon and verify a reconstruction while the state is retained. Record the engine version and selected schema alongside the snapshot. This proposed preparation record separates table evolution from model changes without claiming any new benchmark result or automatic immunity to data leakage.

## Primary references

[Iceberg evolution](https://iceberg.apache.org/docs/latest/evolution/).

[Iceberg Spark queries](https://iceberg.apache.org/docs/latest/spark-queries/).

[Iceberg maintenance](https://iceberg.apache.org/docs/latest/maintenance/).

Related explanations: [Provenance through transformations](/journal/document-markdown-json-provenance/); [Dataset split boundaries](/journal/document-level-data-split-leakage/).
