feat: add fast field support for Bytes type#2830
Merged
fulmicoton merged 1 commit intomainfrom Feb 11, 2026
Merged
Conversation
## What Enable range queries and TopN sorting on `Bytes` fast fields, bringing them to parity with `Str` fields. ## Why `BytesColumn` uses the same dictionary encoding as `StrColumn` internally, but range queries and TopN sorting were explicitly disabled for `Bytes`. This prevented use cases like storing lexicographically sortable binary data (e.g., arbitrary-precision decimals) that need efficient range filtering. ## How 1. **Enable range queries for Bytes** - Changed `is_type_valid_for_fastfield_range_query()` to return `true` for `Type::Bytes` 2. **Add BytesColumn handling in scorer** - Added a branch in `FastFieldRangeWeight::scorer()` to handle bytes fields using dictionary ordinal lookup (mirrors the existing `StrColumn` logic) 3. **Add SortByBytes** - New sort key computer for TopN queries on bytes columns ## Tests - `test_bytes_field_ff_range_query` - Tests inclusive/exclusive bounds and unbounded ranges - `test_sort_by_bytes_asc` / `test_sort_by_bytes_desc` - Tests lexicographic ordering in both directions
stuhood
approved these changes
Feb 10, 2026
| pub struct SortByBytes { | ||
| column_name: String, | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
So, because UTF8 sorts correctly bytewise, the SortByString SortKeyComputer could be implemented 98% in terms of the SortByBytes implementation, with a final UTF8 decode wrapped around the convert_segment_sort_key call.
Almost all string decoding is already avoided though, so it would just allow for some code reuse.
fulmicoton
approved these changes
Feb 11, 2026
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.
What
Enable range queries and TopN sorting on
Bytesfast fields, bringing them to parity withStrfields.Why
BytesColumnuses the same dictionary encoding asStrColumninternally, but range queries and TopN sorting were explicitly disabled forBytes. This prevented use cases like storing lexicographically sortable binary data (e.g., arbitrary-precision decimals) that need efficient range filtering.How
is_type_valid_for_fastfield_range_query()to returntrueforType::BytesFastFieldRangeWeight::scorer()to handle bytes fields using dictionary ordinal lookup (mirrors the existingStrColumnlogic)Tests
test_bytes_field_ff_range_query- Tests inclusive/exclusive bounds and unbounded rangestest_sort_by_bytes_asc/test_sort_by_bytes_desc- Tests lexicographic ordering in both directions