Skip to content

Update Iceberg identifier fields when a record key becomes optional - #1056

Closed
Robotcell wants to merge 1 commit into
apache:mainfrom
Robotcell:fix/iceberg-identifier-fields-nullable-key
Closed

Robotcell wants to merge 1 commit into
apache:mainfrom
Robotcell:fix/iceberg-identifier-fields-nullable-key

Conversation

@Robotcell

@Robotcell Robotcell commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes #1034

What is the purpose of the pull request

Fix the Iceberg schema sync failure Cannot add field id as an identifier field: not a required field that happens when a required record key of an existing Iceberg target becomes nullable. IcebergSchemaSync made the column optional but left it in the identifier fields.

Brief change log

  • IcebergSchemaSync.sync calls UpdateSchema.setIdentifierFields(latest.identifierFieldNames()) when the identifier fields of the current and latest schema differ. Nothing new is called when they are unchanged.
  • Added testIdentifierFieldsRemovedWhenKeyBecomesOptional (real Iceberg InMemoryCatalog table, reproduces the issue scenario) and testIdentifierFieldsNotTouchedWhenUnchanged (mock) to TestIcebergSchemaSync.

Verify this pull request

This change added tests and can be verified as follows:

  • mvn -pl xtable-core -am test -Dtest=TestIcebergSchemaSync (JDK 25): the new tests pass. testSyncWithProvidedIds fails the same way without my change (Mockito cannot mock BaseTable on JDK 25).
  • spotless:check on xtable-core passes (JDK 11).
  • NOT run: the full test suite, and the end-to-end Spark/Hudi pluggable table format reproduction from the issue.
  • The commit is signed off (-s). It has no Generated-by token (recommended, not required, by the ASF generative tooling guidance); I can add one on request.

AI disclosure

This change was prepared with Claude Code (AI assistance) and verified by running the project's tests/CI. The account owner did not review the code line by line.

🤖 Generated with Claude Code

IcebergSchemaSync made a required column optional but left it in the
identifier fields, so the schema commit failed with 'Cannot add field id as
an identifier field: not a required field'. Sync the identifier fields with
the latest schema whenever they differ.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Robotcell <105160953+Robotcell@users.noreply.github.com>
@Robotcell

Copy link
Copy Markdown
Author

Closing this PR: it turns out the project's contribution policy doesn't accept commits prepared with AI assistance (or requires line-by-line human review), which I can't satisfy. Sorry for the noise.

@Robotcell Robotcell closed this Nov 25, 2026
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.

Iceberg schema sync fails when a required record key becomes nullable ("Cannot add field ... as an identifier field")

1 participant