Repository navigation
[1034] Reconcile Iceberg identifier fields in schema sync when a record key becomes nullable - #1057
Open
shubhammittal92 wants to merge 1 commit into
Open
shubhammittal92 wants to merge 1 commit into
shubhammittal92 wants to merge 1 commit into
Conversation
…rd key becomes nullable IcebergSchemaSync.sync applied column updates (including makeColumnOptional) but never reconciled the table's identifier-field set. When an existing table had a required record-key/identifier field that the source later evolved to nullable, the commit failed with: "Cannot add field <name> as an identifier field: not a required field". After applying the column updates, reconcile the identifier set to the latest schema whenever the identifier field ids differ. This reuses the identifier set IcebergSchemaExtractor already computes correctly (empty when any record key is nullable) instead of duplicating that logic, and closes the general gap that sync never propagated identifier-field changes. Tests: added mock unit tests in TestIcebergSchemaSync plus a real HadoopTables end-to-end test (TestIcebergSchemaSyncIdentifierReconcile) that fails with the exact exception before the fix and passes after. Signed-off-by: Shubham Mittal <shubmittal.92@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1034
What is the purpose of the pull request
IcebergSchemaSync.syncapplied column updates (includingmakeColumnOptional) but never reconciled the table's identifier-field set. When an existing Iceberg table had a required record-key/identifier field that the source later evolved to nullable, the commit failed with:IcebergSchemaExtractor.toIcebergalready handles this for brand-new schemas (it drops identifier fields when any record key is nullable), but the sync path for existing tables never propagated identifier-field changes, leaving a stale identifier set that Iceberg rejects at commit.Brief change log
IcebergSchemaSync.sync, reconcile the identifier set to the latest schema (updateSchema.setIdentifierFields(latest.identifierFieldNames())) whencurrent.identifierFieldIds()differs fromlatest.identifierFieldIds(). This reuses the identifier set the extractor already computes correctly (empty when any record key is nullable) instead of duplicating the all-or-nothing rule.TestIcebergSchemaSync(identifier set reconciled on required→optional transition; unchanged identifier fields are not re-synced).TestIcebergSchemaSyncIdentifierReconcile, a realHadoopTablesend-to-end test.Verify this pull request
This change added tests and can be verified as follows:
TestIcebergSchemaSyncIdentifierReconcilecreates a real Iceberg table with a required identifier field, evolves that field to nullable, syncs, and commits. It fails with the exact exception above before this fix and passes after, asserting the field becomes optional and the identifier set is cleared.TestIcebergSchemaSyncverify thesetIdentifierFieldsinteraction.xtable-coreiceberg test suite passes;spotless:checkis clean.