Repository navigation
fix(parquet/variant): correct binary search bounds in ObjectValue.ValueByKey - #841
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a correctness bug in parquet/variant where ObjectValue.ValueByKey’s binary search used an exclusive upper bound but updated it as if it were inclusive, causing certain keys (notably at mid-1) to be skipped for objects with 32+ fields.
Changes:
- Correct binary search upper-bound update in
ObjectValue.ValueByKeyfromj = mid - 1toj = midfor a[i, j)search interval. - Add a regression test that builds a 32-field object and verifies all keys are retrievable via
ValueByKey.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| parquet/variant/variant.go | Fixes binary search bounds update to match exclusive-upper-bound interval semantics. |
| parquet/variant/variant_test.go | Adds a regression test that exercises the binary-search path (32 elements) and validates lookups for all keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
qzyu999
force-pushed
the
fix/variant-object-binary-search
branch
from
June 7, 2026 18:27
1f91ec8 to
9a16c3b
Compare
Contributor
Author
|
Hi @zeroshade, removed an empty line that was breaking the linter in 9a16c3b. |
zeroshade
approved these changes
Jun 8, 2026
laskoviymishka
pushed a commit
to apache/iceberg-go
that referenced
this pull request
Jun 10, 2026
## Changes Bumps arrow-go to [88561cf](apache/arrow-go@88561cf) to pick up apache/arrow-go#840 and [#841](apache/arrow-go#841) (variant fixes; neither reachable via iceberg-go's public API). The bump window includes unrelated Parquet encoder changes (arrow-go #779/#786/#807) that produce different output bytes; tests asserting exact file/column sizes are updated accordingly. Adds defensive coverage at the variant boundary in literals_test.go and table/arrow_utils_test.go. Will follow up to swap the pseudo-version for a tagged release when arrow-go cuts one. Refs #929
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
Closes #842
The
ObjectValue.ValueByKeyfunction implements a custom binary search on thev.valuearray of field IDs to look up fields by key. It initializes its boundaries using an exclusive upper bound (i, j := 0, n).However, when the target key is smaller than the key at the
midindex, it updates the upper bound with:j = mid - 1Since
jis exclusive, setting it tomid - 1excludes the indexmid - 1from the search space entirely. If the target key is located atmid - 1, the lookup will fail and returnarrow.ErrNotFound. This results in missing fields or lookups failing on objects containing >= 32 fields.What changes are included in this PR?
ObjectValue.ValueByKeyfromj = mid - 1toj = mid.Are these changes tested?
TestObjectBinarySearchinparquet/variant/variant_test.gowhich constructs a 32-field object and verifies that all 32 lookups usingValueByKeysucceed.Are there any user-facing changes?