Skip to content

Remove variant_get_json - #192

Merged
sdf-jkl merged 1 commit into
mainfrom
sdf-jkl/drop-variant-get-json
Nov 13, 2026
Merged

sdf-jkl merged 1 commit into
mainfrom
sdf-jkl/drop-variant-get-json

Conversation

@sdf-jkl

@sdf-jkl sdf-jkl commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Part of #141.

variant_get_json(v, path) has no Spark counterpart. Spark writes it as to_json(variant_get(v, path)), which already works here and returns the same JSON text, including quotes around strings. This removes variant_get_json instead of keeping it as a documented extension, one of the options in the "Functions with no Spark 4.2 counterpart" item of #141.

It also panics on shredded input. It reads rows through VariantArray::iter(), and for a shredded object VariantArray::value(i) panics with try_value cannot materialize typed_value of type Struct ... call unshred_variant first. For example, variant_get_json(v, '$.a') over a Parquet file written with 'variant.shredding' '{"v":"STRUCT<a VARCHAR>"}' panics instead of returning an error, while to_json(variant_get(v, '$.a')) reads the same file correctly because variant_get handles shredded columns.

Keeping its kernel as a rewrite target for to_json(variant_get(...)) would not pay off either. In a local Criterion benchmark over 8,192 unshredded rows (direct UDF calls, two runs), the fused function was about 20% faster for a string at $.a (2.9 vs 3.7 ms, 3.8 vs 4.4 ms) and 11 to 28% slower for a nested object (12.0 vs 10.7 ms, 14.7 vs 10.6 ms), with 20 to 30% drift between runs. Both forms produced identical JSON on those inputs. The composed form serializes with Arrow's batch variant_to_json kernel instead of allocating one String per row.

Breaking changes:

  • The variant_get_json SQL function and the VariantGetJsonUdf Rust type are removed. Use to_json(variant_get(v, path)).
  • List paths go with it. variant_get_json was the only function that accepted a list of field names, such as variant_get_json(v, ['a.b', 'c']). Every path is now a Spark $ string, here $['a.b'].c.

The typed-getter macro and the per-row and list-path helpers in src/shared.rs had no other callers and are removed as well. variant_root_paths.slt drops its variant_get_json columns and keeps the scalar input, column path NULL case as to_json(variant_get(...)).

Validation: cargo test, cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --all -- --check, cargo doc --no-deps, and typos on the changed files all pass. The shredded panic was reproduced on main with a scratch SLT, not added as a test because the function is removed.

🤖 Generated with Claude Code

Spark has no `variant_get_json`. Its spelling, `to_json(variant_get(v,
path))`, already works and returns the same JSON. The fused function
also panicked on shredded objects, since it read rows through
`VariantArray::value`.

Remove the UDF, the typed-getter macro, and the per-row and list-path
helpers it alone used. List paths are gone with it, so every path is a
Spark `$` string.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sdf-jkl
sdf-jkl marked this pull request as ready for review November 13, 2026 19:28
@sdf-jkl
sdf-jkl merged commit f2d5b87 into main Nov 13, 2026
6 checks passed
@sdf-jkl
sdf-jkl deleted the sdf-jkl/drop-variant-get-json branch November 13, 2026 19:34
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.

1 participant