Repository navigation
perf: Collapse nested variant_get calls - #188
Merged
Merged
Conversation
Chained `:` access such as `data:commit:collection` plans to nested `variant_get` calls, which rebuild the intermediate Variant row by row instead of reading shredded columns. Add `simplify` to `variant_get` and `try_variant_get` to merge an untyped inner getter with literal paths into one getter over the combined path. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-variant-get Adapt the nested getter rewrite to the Spark `$`-only path syntax (#187): paths are now concatenated textually, and a SQL NULL path is not collapsed as it returns SQL NULL rather than selecting the root. Co-Authored-By: Claude Fable 5.2 <[email protected]>
variant_get calls into a single pathvariant_get calls into a single path
variant_get calls into a single pathvariant_get calls
alamb
commented
Nov 13, 2026
| /// | ||
| /// # Background | ||
| /// | ||
| /// A single call is more efficient as it can read shredded columns directly, |
Collaborator
Author
There was a problem hiding this comment.
this is the key writeup / function -- I tried to document it as well as I could
| } | ||
|
|
||
| fn simplify(&self, args: Vec<Expr>, _info: &SimplifyContext) -> Result<ExprSimplifyResult> { | ||
| simplify_getter(self, args) |
Collaborator
Author
There was a problem hiding this comment.
I am quite pleased with how nicely this API works
| parse_variant_path(outer, true)?; | ||
| // Each element of a valid path starts with `.` or `[`, so the elements of | ||
| // `outer` can directly follow those of `inner`. | ||
| Ok(format!("{inner}{}", &outer[1..])) |
Collaborator
Author
There was a problem hiding this comment.
@sdf-jkl , your change to only support spark style made this function quite a bit simpler
sdf-jkl
added a commit
that referenced
this pull request
Nov 13, 2026
Follow-up to #188. Move getter tests into variant_get.slt and path tests into variant_path.slt, dropping cases that repeat each other or existing coverage. Restore the usable-Variant check that #188's collapsing hollowed out, and pin the shredded missing-field and out-of-bounds behavior chained `:` now shares with single paths (apache/arrow-rs#11191, apache/arrow-rs#11050). Co-authored-by: Claude Opus 5.5 <[email protected]>
sdf-jkl
added a commit
that referenced
this pull request
Nov 13, 2026
#188 fuses nested getters, so `v:a:b` now reads the same path as `v:a.b` in one lookup. Say so instead of listing it as slower. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 13, 2026
sdf-jkl
added a commit
that referenced
this pull request
Nov 18, 2026
* Document the Variant path syntax Add a "Variant paths" page to the User Guide covering `$` paths, quoting, the `:` operator, `variant_delete`, rootless paths, and differences from Spark 4.2. Every claim is checked by the docs harness. Point the `path` arguments of `variant_get`, `try_variant_get`, and `variant_delete` at the page instead of repeating the grammar, and link it from the cookbook's `:` example. Closes #170. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update the path docs for `$`-only paths #187 rejects paths without `$`, returns SQL NULL for a SQL NULL path, and builds `:` paths the way Spark does. Drop the rootless and Spark-differences sections, show how `:` builds its path, and fold the `variant_delete` rule into the syntax section. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Trim the path docs Fold the whole-value and `$.*` checks into the existing hidden query, and state the `:` rule once with inline examples instead of a table. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Explain `:` versus `.` in the path docs Show that `:` starts a path and `.` continues it, that chaining `:` runs one lookup per `:` (#176), and that `.` alone is struct field access. Link JSONPath (RFC 9535) and note that quoted names have no escapes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Reorganize and trim the path docs Group the page into syntax, NULLs and errors, and the `:` operator. Show the `$.http.status` trap in the main example, collect the `:` pitfalls in one table, pretty-print the example JSON, and merge the hidden checks into fewer table-driven queries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Drop the chained `:` pitfall from the path docs #188 fuses nested getters, so `v:a:b` now reads the same path as `v:a.b` in one lookup. Say so instead of listing it as slower. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Show path doc checks as examples Hidden checks pinned outputs that readers never saw. Show the quoting, NULL, and chained `:` results as examples and trim the prose they replace. Only the expected-error checks stay hidden. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Scope path NULL rules to the getters in the path docs `variant_delete` leaves the value unchanged for a missing target and skips a NULL path, so the SQL NULL rule only covers `variant_get`, `try_variant_get`, and `:`. Also call the syntax "based on" JSONPath, since `$.*` and `\` differ from RFC 9535, and name the chained `:` example. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Apply suggestion from @alamb Co-authored-by: Andrew Lamb <[email protected]> * Address review of the path docs Add an Escaping section that reuses the `requests` table, and keep the JSONPath differences with the syntax. Trim NULL handling to missing paths and link the common pitfalls page, since the function reference already covers NULL paths and `variant_delete`. Move the failing `:` forms to common pitfalls. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Andrew Lamb <[email protected]>
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.
Chained
:access such asIs planned as nested calls like
This is inefficient as it rebuilds an intermediate Variant instead of reading the shredded column directly
Changes
variant_get/try_variant_getthat merges an untyped inner getter into the outer one when possibleI verified this locally from the issue using the repro from #176: