Add array-index support to Parquet variant field extraction#2
Closed
vuule wants to merge 2 commits into
Closed
Conversation
Extend the JSONPath-like path used by get_variant_field/extract_variant_field
to descend into array values via zero-based "[N]" steps, in addition to the
existing object-key descent.
- variant_path.cpp: parse "[<non-negative integer>]" steps, preserving the
literal "[N]" token so the GPU path walker can distinguish index steps from
object-key steps by their first byte. Wildcards ("[*]"), negative indices,
quoted names in brackets, and unterminated brackets throw.
- variant_extract.cu: add locate_array_element (parses the array value header
and returns the N-th element's subspan) and dispatch on "[" in resolve_path.
- variant.hpp: document the extended path grammar and array-indexing behavior.
- Tests: positive int8 array indexing, out-of-bounds / type-mismatch nulls, and
updated SyntaxErrors to accept "$.a[0]" while rejecting "$.a[-1]" and "$.a[1".
Verified locally: VARIANT_EXTRACT_TEST 33/33 pass.
Owner
Author
|
Closing: re-doing this as a proper stacked PR via gh stack (the fork-internal base was not the intended mechanism). |
Reject out-of-range "[N]" indices at parse time (std::from_chars bound to cudf::size_type) and accumulate the index in uint64_t on the GPU path walker to avoid signed-int32 overflow (UB). Add a SyntaxErrors case for an over-long index, document that out-of-range indices throw, and note that array element offsets are monotonic (unlike object field offsets).
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.
Summary
Stacked on top of the PR2 branch (rapidsai#22416). Extends the JSONPath-like
path used by
get_variant_field/extract_variant_fieldto descend into VARIANTarray values via zero-based
[N]index steps, in addition to the existingobject-key descent.
variant_path.cpp: parse[<non-negative integer>]steps, preserving theliteral
[N]token so the GPU-side path walker can distinguish index steps fromobject-key steps by their first byte.
[*]wildcards, negative indices, quotednames inside
[...], and unterminated brackets throwstd::invalid_argument.variant_extract.cu: addlocate_array_element(parses the array valueheader —
num_elements+ offsets — and returns the N-th element's subspan) anddispatch on a leading
[inresolve_path.variant.hpp: document the extended path grammar and array-indexing behavior(e.g.
"$[0]","$.a[0].b").an updated
SyntaxErrorscase (now accepts"$.a[0]", still rejects"$.a[-1]","$.a[1","$.a[*]", ...).Notes for reviewers
Next PR in the VARIANT extraction stack (rapidsai#22310 merged -> rapidsai#22416 -> this). Base is
pr2-variant-field-extraction-core; retarget tomainonce rapidsai#22416 merges. Diff isarray-indexing only - the binary-search metadata optimization from the feature
branch is intentionally not included here and will land separately.
Test plan
VARIANT_EXTRACT_TESTbuilds and passes locally (33/33), including the newarray-indexing tests.
Made with Cursor