Parquet: Fix variant STRING metrics bounds to use UTF-8 byte order - #17397
Open
vishnuprakaz wants to merge 1 commit into
Open
Parquet: Fix variant STRING metrics bounds to use UTF-8 byte order#17397vishnuprakaz wants to merge 1 commit into
vishnuprakaz wants to merge 1 commit into
Conversation
uros-b
approved these changes
Jul 28, 2026
Member
|
Nice fix, thank you @vishnuprakaz! |
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.
Rationale for this change
Queries over a shredded variant
STRINGcolumn can silently return wrong (missing) results a file that actually contains matching rows gets skipped.variant string bounds are aggregated across row groups with
String.compareTo(UTF-16 code-unit order), but Parquet's per-column stats and the scan-time evaluator (Comparators.charSequences()) use UTF-8 byte order.The two disagree when a supplementary-plane character (code point ≥ U+10000, e.g. an emoji a surrogate pair starting
0xD800) is compared with a BMP character inU+E000–U+FFFF:String.compareToranks the supplementary char below it (0xD800<0xE000), UTF-8 ranks it above. For a string column spanning multiple row groups with that mix, the aggregated lower/upper bounds invert, and the evaluator (UTF-8 order) then prunes files that match.The
BINARYbranch already usesComparators.unsignedBytes(), and the non-variantParquetMetricspath usesComparators.charSequences()forstrings; only the variant
STRINGbranch fell through tonaturalOrder(). Same class as #16880.What changes are included in this PR?
Use
Comparators.charSequences()forSTRINGinParquetVariantUtil.comparator(), matching theBINARYbranch and the string ordering usedelsewhere.
Are these changes tested?
Yes.
TestVariantMetrics.testShreddedStringBoundsAcrossRowGroupswrites a shredded string variant across multiple row groups mixingU+E000andU+10000and asserts the bounds are not inverted fails before the fix, passes after. Existing tests used single-row-group ASCII values, so this path was uncovered.Are there any user-facing changes?
No API changes.
Present in 1.9.0–1.11.0; backports to 1.10.x and 1.11.x. will do follow up.