Repository navigation
fix(variant): support closing brackets inside quoted path fields - #11231
Merged
sdf-jkl merged 2 commits intoOct 2, 2026
Merged
Conversation
sdf-jkl
enabled auto-merge
October 2, 2026 21:11
Member
|
Thanks again @DKER2 🚀 |
codewarnab
pushed a commit
to codewarnab/arrow-rs
that referenced
this pull request
Oct 27, 2026
# Which issue does this PR close? - Closes apache#9493. # Rationale for this change `parse_in_bracket` currently allocates a `String` for every bracket expression, including indexes, wildcards, and quoted fields that require no unescaping. `VariantPathElement::Field` already stores `Cow<str>`, so unescaped field names can borrow directly from the input path. # What changes are included in this PR? - Defer creation of the unescaped `String` until the first backslash is encountered. - Borrow the original bracket-content slice when no escape processing is required. - Preserve ownership for escaped fields and strip their surrounding quotes in place. - Add tests proving unescaped bracket fields use `Cow::Borrowed` while escaped fields use `Cow::Owned`. This branch includes `main` with apache#11231 (closing brackets inside quoted fields). The quote tracking added there relied on the eagerly built buffer, so it is adapted here: an opening quote is now detected by its offset in the bracket content rather than by the buffer being empty, and quoted fields containing `]` (e.g. `['a]b']`) still borrow. # Are these changes tested? Yes. The existing path parsing tests cover behavior, and a new test asserts the ownership of each case: empty, plain, and `]`-containing quoted fields are borrowed, and an escaped field is owned. The benchmark for this change is in apache#11508 (`cargo bench -p parquet-variant --bench variant_path`), split out as requested so it is available on `main` as a baseline. I will merge `main` here once it lands so the numbers can be reproduced. Earlier local measurements, taken with a temporary Criterion harness on aarch64 macOS before apache#11231 was merged in: | Case | Before | After | Change | |---|---:|---:|---:| | Three quoted bracket fields | 300.22 ns | 54.10 ns | -81.7% | | Three bracket indexes | 146.13 ns | 45.57 ns | -68.2% | | Escaped bracket field | 140.41 ns | 111.37 ns | -24.9% | | Dot-path control | 38.68 ns | 40.88 ns | Within noise | # Are there any user-facing changes? No semantic or public API changes. Parsed paths remain the same; unescaped bracket fields now borrow their names instead of allocating owned strings. # AI usage OpenAI Codex was used to inspect the parser, help implement the lazy allocation path, construct ownership tests, and run validation and benchmarks. Claude Code was used to adapt the change to apache#11231 after merging `main`. I reviewed the resulting code and behavior and can own and debug the change. --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Kosta Tarasov <[email protected]>
8 of 35 tasks
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.
Which issue does this PR close?
Rationale for this change
Quoted VariantPath fields can contain a literal closing bracket, but the parser currently terminates the bracket segment at the first unescaped
], even when it appears inside matching quotes. This rejects paths such as["a]b"]and can silently split some field names into multiple path elements.What changes are included in this PR?
]as the closing delimiter only outside matching quotes.\]escape behavior.Are these changes tested?
Yes. The following checks pass:
cargo test -p parquet-variantcargo clippy -p parquet-variant --all-targets --all-features -- -D warningscargo +stable fmt --all -- --checkgit diff --checkAre there any user-facing changes?
Yes. Quoted VariantPath fields may now contain an unescaped
]. Existing paths using\]remain supported. There are no public API changes.AI usage
OpenAI Codex was used to inspect the existing parser, help implement the quote-state change, add regression tests, and run validation. I reviewed the resulting code and test behavior and can own and debug the change.