Skip to content

fix: resolve current_schema via current_schema_id, not the snapshot pin - #378

Merged
JanKaul merged 2 commits into
JanKaul:mainfrom
cedricziel:fix/current-schema-resolution
Jul 29, 2026
Merged

fix: resolve current_schema via current_schema_id, not the snapshot pin#378
JanKaul merged 2 commits into
JanKaul:mainfrom
cedricziel:fix/current-schema-resolution

Conversation

@cedricziel

Copy link
Copy Markdown
Contributor

Fixes #376.

TableMetadata::current_schema preferred the current snapshot's pinned schema_id over current_schema_id. That made SetCurrentSchema unreachable on any table that already has a snapshot: the old snapshot pins the old schema id, and the Append/Replace operations stamp their new snapshot's schema_id from current_schema(), re-pinning the old schema on every commit — so a schema evolution could never take effect and writers (which derive their Arrow schema from current_schema) kept producing the old shape.

Per the Iceberg spec, the table's authoritative schema is current-schema-id; a snapshot's schema-id records the schema that was current when that snapshot was written, and stays reachable via TableMetadata::schema(snapshot_id) for snapshot-scoped reads (time travel is unaffected).

With this change the four snapshot-stamping sites in operation.rs (which all call current_schema()) automatically stamp new snapshots with the current schema id, so the AddSchema → SetCurrentSchema → write sequence works end to end.

Includes a regression test: metadata with schemas {0, 1}, current-schema-id: 1, and a snapshot pinned to schema 0 — current_schema(None) must return schema 1 while schema(snapshot_id) still returns schema 0.

Context: SignalDB drives schema evolution from its compaction path (cedricziel/signaldb#734) and hit this as a hard blocker.

TableMetadata::current_schema preferred the current snapshot's pinned
schema_id over current_schema_id. That made SetCurrentSchema unreachable
on any table with a snapshot: the old snapshot pinned the old schema id,
and the Append/Replace operations stamp their new snapshot's schema_id
from current_schema(), re-pinning the old schema on every commit — so a
schema evolution could never take effect and writers kept producing the
old shape.

Per the Iceberg spec, the table's authoritative schema is
current-schema-id; a snapshot's schema-id records the schema that was
current when the snapshot was written (still reachable through
TableMetadata::schema(snapshot_id) for snapshot-scoped reads).

Fixes JanKaul#376.

@JanKaul JanKaul left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot the PR. The changes look good. I left a minor comment.

Comment thread iceberg-rust-spec/src/spec/table_metadata.rs Outdated
…tion_fields

The table's current schema is a table-level property (current-schema-id)
and does not vary by branch, so the parameter was dead. Remove it from
TableMetadata::current_schema, TableMetadata::current_partition_fields,
and the Table::current_schema delegate, and drop the now-unused branch
plumbing from the crate-internal ManifestWriter and ManifestListWriter
constructors. Views and materialized views keep their branch parameter,
where the schema legitimately varies by version ref.

Addresses review feedback on JanKaul#378.
@cedricziel
cedricziel requested a review from JanKaul July 29, 2026 08:06
@JanKaul
JanKaul merged commit a34ce53 into JanKaul:main Jul 29, 2026
2 checks passed
cedricziel added a commit to cedricziel/signaldb that referenced this pull request Jul 29, 2026
… bloom filters (#774)

Pulls in JanKaul/iceberg-rust#378 (current_schema resolves via
current_schema_id instead of the snapshot pin, unblocking schema
evolution from the compaction path, #734) and #379 (per-column
bloom-filter table properties in the Parquet writer).

Adapts to the breaking signature change (current_schema no longer takes
a branch parameter) and un-ignores
test_schema_evolution_add_label_column, which was blocked on exactly
the bug #378 fixed and now passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema evolution: Append/Replace snapshots re-pin the pre-evolution schema_id, so SetCurrentSchema never takes effect

2 participants