UpdateSchema.BuildUpdates should select newly added schemas with schema-id: -1

Open Beginner friendly
#2,586 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@nisan1101 is already working on this.

Since Nov 13, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
databases

Research direction

Start with UpdateSchema.BuildUpdates() in table/update_schema.go at the cited lines and compare the new-schema branch with the branch that selects an existing schema. Change the new-schema selection to use -1, while retaining the existing explicit ID and AssertCurrentSchemaID requirement; verify that the emitted updates select the schema added by the request.

Written by the indexing model from the issue text.

Description

Apache Iceberg version

v0.7.0 and main (development), checked at 8d13e317c79f36f38f52a16b2f81f1d966f1fc27.

Please describe the bug 🐞

UpdateSchema.BuildUpdates() emits these updates when adding a new schema:

NewAddSchemaUpdate(newSchema),
NewSetCurrentSchemaUpdate(newSchema.ID),

The second update uses a client-predicted schema ID. If another writer registers a different schema between our metadata read and commit, the catalog can assign our schema a different ID, causing set-current-schema to select the other writer's schema.

Relevant source.

Reproduction scenario
  1. A table has current schema ID 0, containing fields a, b, and c.
  2. Writer A reads that metadata and uses UpdateSchema.BuildUpdates() to drop b. Its updates add schema {a, c} and select predicted schema ID 1.
  3. Before A commits, writer B registers schema {a, b} with ID 1, without making it current.
  4. A commits its previously built updates.
  5. The catalog assigns A's schema ID 2, but A's set-current-schema still selects ID 1.

The commit selects B's schema {a, b} instead of A's intended schema {a, c}.

AssertCurrentSchemaID(0) still passes because B did not change the current schema. Even an additional AssertLastAssignedFieldID requirement does not catch this case because B added no field IDs.

Expected behavior / proposed fix

After adding a new schema, emit:

NewAddSchemaUpdate(newSchema),
NewSetCurrentSchemaUpdate(-1),

The REST Catalog specification defines schema-id as:

Schema ID to set as current, or -1 to set last added schema

Using -1 selects the schema added by this request using its actual assigned ID. The branch that selects an already-existing schema should continue using that schema's explicit ID, and the existing AssertCurrentSchemaID requirement should remain.

Dominant language
Go
Stars
477
Forks
262
Avg merge
1d 23h
Merged PRs (30d)
303

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iceberg-go

All issues in apache/iceberg-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.