Repository navigation
Accept only Spark $ Variant paths - #187
Merged
Merged
Conversation
Drop the rootless Arrow path dialect. Paths must start with `$`, as in Spark 4.2. The `:` operator builds `$` paths the way Spark does, root casts read `$`, and a SQL NULL path returns SQL NULL. Closes #166. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep one SLT per rejected-path rule and fold NULL-path coverage into the existing column-path queries. Each NULL branch, the root cast, and the `:` prefix still fail the suite when reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sdf-jkl
marked this pull request as ready for review
November 12, 2026 22:08
sdf-jkl
added a commit
that referenced
this pull request
Nov 12, 2026
#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]>
alamb
reviewed
Nov 12, 2026
| SELECT variant_get(data, 'did', 'VARCHAR') AS user_id, | ||
| MAX(variant_get(data, 'time_us', 'BIGINT')) / 1000 | ||
| - MIN(variant_get(data, 'time_us', 'BIGINT')) / 1000 AS activity_span | ||
| SELECT variant_get(data, '$.did', 'VARCHAR') AS user_id, |
Collaborator
There was a problem hiding this comment.
this syntax now looks even worse -- maybe we can switch these to using : syntax
Collaborator
Author
There was a problem hiding this comment.
this syntax now looks even worse
😿
... a column containing the extraction path strings or a string representing the extraction path. A valid path should start with $ and is followed by zero or more segments like A column that evaluates to a string. [123], .name, [‘name’], or [“name”]. ...
maybe we can switch these to using : syntax
👍 explicit getter invocation is not necessary, just one way of doing it. : is definitely more 👁️ 🍬
Collaborator
There was a problem hiding this comment.
I'll make a PR to do it after this
So we won't mess up performane
alamb
added a commit
that referenced
this pull request
Nov 13, 2026
…-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]>
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]>
sdf-jkl
added a commit
to sdf-jkl/datafusion-variant
that referenced
this pull request
Nov 23, 2026
Scope the page to Spark 4.2.0, drop rows made stale by datafusion-contrib#143, datafusion-contrib#153, datafusion-contrib#187 and datafusion-contrib#192, link tests with absolute URLs, and add the page to the docs site and the README note. Enable field-extraction case 04 (fixed by apache/arrow-rs#11302) and the empty-key schema_of_variant case (apache/arrow-rs#10352), which pass on Arrow 60.1.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alamb
pushed a commit
that referenced
this pull request
Nov 28, 2026
* Document Spark compatibility differences and their causes * Rewrite Spark compatibility page for Spark 4.2 and enable fixed cases Scope the page to Spark 4.2.0, drop rows made stale by #143, #153, #187 and #192, link tests with absolute URLs, and add the page to the docs site and the README note. Enable field-extraction case 04 (fixed by apache/arrow-rs#11302) and the empty-key schema_of_variant case (apache/arrow-rs#10352), which pass on Arrow 60.1.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Drop the function list and ask readers to report differences Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[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.
Closes #166.
Variant path arguments now follow Spark 4.2 only. Until now, a path starting with
$used the Spark parser from #143, and anything else fell back to the ArrowVariantPathgrammar, with different escaping and with'$type'meaning something else in each dialect. This drops the rootless dialect instead of keeping both.variant_get(v, 'a.b')a, thenbinvalid Variant path "a.b": paths start withvariant_get(v, '')variant_get(v, p)wherepis SQL NULLv:a.b,v:['k']'a.b',"['k']"'$.a.b',"$['k']", built like Spark'svisitSemiStructuredExtract:operator keeps working and keeps its column names (events.event:name). Sincev:aandvariant_get(v, '$.a')are now the same expression, both are namedv:a.CAST(variant AS type)lowers tovariant_get(v, '$', type)instead of''.variant_get,try_variant_getandvariant_get_json, for scalar and column paths.variant_object_keysstill rejects a NULL path, as before.:now keep backslashes, like every other$path (Spark 4.2). For example,v:["a\b"]selects the fielda\b, notab.This is a breaking change for anyone using rootless paths: the only release, 0.1.0, predates
$paths. The error message names the fix. Spark-style paths in arrow-rs are tracked in apache/arrow-rs#11627, and theTODO(arrow-rs)onparse_rooted_pathdrops this crate's parser once that lands.Most of the diff rewrites rootless paths to
$paths in the SLTs, docs, doctests, CLI tests, JSONBench queries and benches. Tests that compared the two dialects now check that rootless paths are rejected, the\]case that relied on Arrow escaping is gone, and$['a]b']is no longer skipped.variant_root_paths.sltadds rejection cases for rootless and empty paths, and NULL paths for scalar and column Variants with literal and column paths.Validation
The grammar, NULL handling and
:path building were checked against Spark'sv4.2.0source.cargo test --workspace(unit, SLT, doctests, the docs harness and CLI integration),cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warningsandcargo bench --bench variant_get -- --testpass.docs/sql-reference.mdis regenerated. I did not runsphinx-build, and the docs changes are SQL path literals only.🤖 Generated with Claude Code