Skip to content

Share Variant path parsing and support rooted getter paths - #143

Merged
sdf-jkl merged 4 commits into
datafusion-contrib:mainfrom
getChan:shared-variant-paths
Nov 10, 2026
Merged

sdf-jkl merged 4 commits into
datafusion-contrib:mainfrom
getChan:shared-variant-paths

Conversation

@getChan

@getChan getChan commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Share Variant string-path parsing and add Spark-style $ paths to getters and variant_object_keys. Existing rootless paths remain supported; unifying the syntax is deferred to #166 for backward-compatibility review.

Rooted quoted keys preserve backslashes as in Spark 4.2, including for variant_delete. The shared helper takes allow_root; deletion still requires a rooted path and rejects $ alone. Dollar-prefixed field names require bracket quoting, e.g. $["$name"].

Closes #142. Related to #71 and #141.

Validation: cargo test, generated docs and example checks, Clippy, formatting, and license-header checks passed locally.

@getChan
getChan marked this pull request as ready for review November 1, 2026 11:45
@sdf-jkl

sdf-jkl commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Keep both Spark-rooted and existing rootless paths? This implementation supports both, with a TODO to unify them later.

I'd unify them to the Spark root

Accept the compatibility change for $-prefixed field names? $ now selects the root; literal fields require bracket quoting, e.g. $["$name"].

This is great

Keep function-specific restrictions outside the parser? Deletion still requires rooted paths and rejects $ alone.

I think a shared path helper with a parameter to reject $ could do. Spark does smth like that

Rooted quoted keys use newer Spark escape handling. Spark 4.2 treats backslashes literally, so paths such as $['a\nb'] can select different keys. Is this acceptable for the 4.2 compatibility target in #141?

I wonder if we should reverse to the older behavior for the release target parity. variant_delete is outside of 4.2 too

@getChan

getChan commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

I'll track unifying the path syntax with Spark in #166 and handle it separately, taking backward compatibility for existing rootless paths into account. This PR will keep those paths supported while sharing the parser and adding Spark-rooted getter paths.

@getChan getChan closed this Nov 7, 2026
@getChan getChan reopened this Nov 7, 2026
@getChan

getChan commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

I've added a parameter to the shared path helper to control whether $ alone is allowed, and aligned rooted path escaping with Spark 4.2. variant_delete predates this PR, so I've kept the function for backward compatibility even though it isn't part of Spark 4.2.

@alamb alamb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me -- thank you @getChan

cc @sdf-jkl

@alamb

alamb commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Perhaps we can add a documentation page eventually, similar to shredding.md, that documents the supported path syntax

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @getChan 🚀 🚀 🚀

@sdf-jkl
sdf-jkl merged commit bcd265e into datafusion-contrib:main Nov 10, 2026
4 of 8 checks passed
alamb pushed a commit that referenced this pull request Nov 10, 2026
* Enable quoted `]` path tests and simplify Variant path parsing

Arrow 60.1 handles a closing bracket inside quotes, so the skipped
quoted-`]` cases now run. Trim the path tests that #143 left redundant
and simplify the rooted path parser now that quoted keys keep
backslashes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Split bracket path segments with `str::split_once`

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share Variant path parsing across functions and support Spark-style rooted paths

3 participants