Fix: Ensure correct partition spec is set as default in REST catalog #1
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.
Problem
When creating a Paimon table with partition fields that syncs to Iceberg REST catalog, the resulting metadata includes an extra empty partition spec (spec-id: 0) alongside the actual partition spec (spec-id: 1). This causes the REST catalog to have:
Instead of the expected:
Root Cause
The REST catalog integration follows this flow:
createTable()creates an Iceberg table with an empty schema (to handle field ID offsets between Paimon and Iceberg)updatesForCorrectBase()then adds the actual partition spec, which gets assigned spec-id: 1Solution
Since we cannot remove the empty spec-id: 0, this fix ensures that when a new table is created with an empty base spec but a non-empty partition spec in the new metadata:
setDefaultPartitionSpec()This ensures Iceberg readers use the correct partition spec, even though the empty spec-id: 0 remains in the metadata for historical reasons.
Changes
updatesForCorrectBase()for the case where the base has an empty partition spec but the new metadata has a non-empty specLimitations
This fix doesn't remove the empty spec-id: 0 from the metadata (Iceberg doesn't support removing partition specs). However, it ensures the correct spec is used as the default, which resolves the functional issue for Iceberg readers.
Note
Improves partition spec handling during initial table creation against the REST catalog.
spec-id: 0) and the new metadata has a non-empty spec, add the new spec and set it as the default; otherwise usenewMetadata.defaultSpecId()spec-id: 0) that cannot be removedWritten by Cursor Bugbot for commit 9036adc. This will update automatically on new commits. Configure here.