You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "thswlsqls (via GitHub)" <gi...@apache.org> on 2026/06/21 00:19:01 UTC
[PR] Core: Fix SnapshotUtil.schemaFor to look up schema by id [iceberg]
thswlsqls opened a new pull request, #16892:
URL: https://github.com/apache/iceberg/pull/16892
<!-- No issue: minor bug fix, issue not required -->
## Summary
- `SnapshotUtil.schemaFor(TableMetadata, ref)` read the snapshot schema with `metadata.schemas().get(snapshot.schemaId())`.
- `metadata.schemas()` returns a `List<Schema>`, so the schema id was used as a list index.
- When schema ids no longer match list positions, this returns the wrong schema, or throws `IndexOutOfBoundsException` when the id is past the list size.
- Schema ids and list positions diverge after `expireSnapshots().cleanExpiredMetadata(true)` removes an older unreferenced schema.
- The fix looks the schema up by id via `metadata.schemasById()`, mirroring the sibling `schemaFor(Table, long)`, including its `checkState` guard for a missing id.
- This is a latent fix. The only in-tree production caller of this overload, `MergingSnapshotProducer.apply`, passes a branch ref, and branch refs return the table schema earlier in the method. The buggy line is reachable only for tag refs, so this removes an internal inconsistency rather than a live failure.
## Testing done
- Added `TestSnapshotUtil#schemaForTagWithMetadata` (wrong-schema case) and `schemaForTagWithMetadataSchemaIdBeyondListSize` (IndexOutOfBounds case).
- `./gradlew :iceberg-core:test --tests "org.apache.iceberg.util.TestSnapshotUtil"` — 14 tests passed.
- `./gradlew :iceberg-core:spotlessCheck :iceberg-core:checkstyleMain :iceberg-core:checkstyleTest :iceberg-core:revapi` — passed (revapi backward compatible).
- Regression demo: with the fix reverted, both new tests fail (wrong schema, and `ArrayIndexOutOfBoundsException`); restored, both pass.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Core: Fix SnapshotUtil.schemaFor to look up schema by id [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #16892: Core: Fix SnapshotUtil.schemaFor to look up schema by id
URL: https://github.com/apache/iceberg/pull/16892
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Core: Fix SnapshotUtil.schemaFor to look up schema by id [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16892:
URL: https://github.com/apache/iceberg/pull/16892#issuecomment-5137769671
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Core: Fix SnapshotUtil.schemaFor to look up schema by id [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16892:
URL: https://github.com/apache/iceberg/pull/16892#issuecomment-5064886140
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org