[#11980] fix(core): sort column ordinal positions while fetching from entity store#11979
Merged
yuqi1129 merged 1 commit intoJul 13, 2026
Conversation
Code Coverage Report
Files
|
Contributor
Author
|
Hi @yuqi1129 could you please help me with the review! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an ordering bug in the core table load path by ensuring columns are returned in stable ordinal-position order when converting stored TableEntity metadata into a GenericTable. This aligns loadTable/describe behavior with the existing alter-table path and prevents position-based consumers from misinterpreting column mappings.
Changes:
- Sort
tableEntity.columns()byColumnEntity::positioninManagedTableOperations.toGenericTable()before mapping toColumn[]. - Add a unit test that persists a
TableEntitywith an intentionally unordered column list and verifiesloadTable()returns columns ordered by position.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/main/java/org/apache/gravitino/catalog/ManagedTableOperations.java | Sort columns by stored ordinal position when loading tables from the entity store. |
| core/src/test/java/org/apache/gravitino/catalog/TestManagedTableOperations.java | Adds coverage ensuring loadTable() returns columns ordered by position even if the store returns them unordered. |
yuqi1129
approved these changes
Jul 13, 2026
Contributor
|
@MehulBatra |
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.
Closes: #11980
What changes were proposed in this pull request?
Proposed fix:
Sort by position in toGenericTable():
column_position is already persisted correctly, so this fixes existing tables on read with no migration or re-registration. Comparator and ColumnEntity are already imported in the file.
Why are the changes needed?
ManagedTableOperations.toGenericTable() builds the column list from tableEntity.columns() without sorting by position, so loaded tables can return columns in an arbitrary, unstable order even though column_position is stored correctly. This breaks position-based consumers (e.g. the Lance REST catalog), causing wrong column mapping or crashes. The fix sorts columns by position on load, matching what the alter path already does.
Fix: #11980
Does this PR introduce any user-facing change?
No API or property changes.
Behavior fix only: loadTable/describe now always returns columns in their declared position order (previously they could come back unordered). No user-facing API changes, and no property keys added or removed.
How was this patch tested?
Before Fix:

After Fix:

Without sorting:
With sorting: