[BugFix] Reject full-column ORDER BY that reorders key columns of a key-derived range-distribution table (backport #76256)#76282
Merged
Conversation
Contributor
Author
|
Cherry-pick of 10c0fa5 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Contributor
Author
|
@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr |
xiangguangyxg
approved these changes
Jul 13, 2026
8aaa0fc to
4eb3cfe
Compare
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.
Why I'm doing:
On a cloud-native range-distribution table whose sort key is key-derived (created without an explicit
ORDER BY), a full-columnALTER TABLE ... ORDER BYthat permutes the key columns takes the schema-reorder path (processReorderColumn). That reorders the schema — and thus the key-derived range sort key — but the plain lake schema-change job copies each shadow tablet's range verbatim instead of re-sampling. After the flip the sort key is the new key order while the stored boundary tuples are still in the old key-column space, soRangeDistributionPruner(FE) andRangeRouter(BE) compare new-order key tuples against old-order boundaries: silent wrong pruning and mis-routed loads, with no error. The subsetORDER BYform is routed to the range-rewrite job and re-samples, so only the full-column form slips through theorderedColumns.size() != baseSchema.size()dispatch. Reported by @banmoy while reviewing #76047.What I'm doing:
Reject the corrupting case: a full-column
ORDER BYthat permutes the key columns of a key-derived (getSortKeyIdxes() == null) cloud-native range-distribution table now fails with a clear message directing the user to the subsetORDER BY (<sort-key columns>)form, which re-samples the K-tablet boundaries. Cases that are already safe are unaffected: a full reorder that keeps the key order (reorders only value columns), tables created with an explicitORDER BY(the sort key is remapped by name through a reorder), and non-range / non-cloud-native tables. Full support (routing the full reorder to a re-sampling rewrite job) is left as a follow-up enhancement.What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request #76256 done by [Mergify](https://mergify.com).