shubhammittal92 opened a new pull request, #1057: URL: https://github.com/apache/incubator-xtable/pull/1057
Fixes #1034 ## What is the purpose of the pull request `IcebergSchemaSync.sync` applied column updates (including `makeColumnOptional`) 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: ``` java.lang.IllegalArgumentException: Cannot add field <name> as an identifier field: not a required field ``` `IcebergSchemaExtractor.toIceberg` already 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 - After the column updates are applied in `IcebergSchemaSync.sync`, reconcile the identifier set to the latest schema (`updateSchema.setIdentifierFields(latest.identifierFieldNames())`) when `current.identifierFieldIds()` differs from `latest.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. - Added unit tests in `TestIcebergSchemaSync` (identifier set reconciled on required→optional transition; unchanged identifier fields are not re-synced). - Added `TestIcebergSchemaSyncIdentifierReconcile`, a real `HadoopTables` end-to-end test. ## Verify this pull request This change added tests and can be verified as follows: - `TestIcebergSchemaSyncIdentifierReconcile` creates 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. - Mock-based unit tests in `TestIcebergSchemaSync` verify the `setIdentifierFields` interaction. - Full `xtable-core` iceberg test suite passes; `spotless:check` is clean. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
