Repository navigation
fix: return errors for missing Variant metadata field names - #11106
Conversation
|
I had opened an overlapping fallible-builder PR and have closed it in favor of this one. During independent review, we found a separate |
) ### Why `ObjectBuilder` updates its field-offset map before appending a value. With duplicate-key validation enabled, rejecting a duplicate can leave the map changed. With validation disabled, a failed fallible overwrite truncates bytes but leaves the previous offset unrestored. Continuing to build the object can then produce an invalid value. ### Change Reject validated duplicates before mutation and restore the previous offset when a permitted overwrite fails. The default non-validating path keeps its existing `fields.insert` fast path. Add regression tests that continue building after each error. This is independent of the fallible trait API in apache#11106; it is the unique correction extracted from superseded apache#11401. ### Validation - `cargo +1.98.1 test -p parquet-variant --lib`: 176 passed. - Formatting and `cargo +1.98.1 clippy -p parquet-variant --lib` pass (installed 1.98.1 reports the repo's newer lint as unknown). - Focused short Criterion runs showed no repeatable regression, but WSL measurements were noisy; the default insert path is unchanged. - Independent read-only review covered correctness, regressions, performance, API compatibility, and tests; approved with no blockers.
# Which issue does this PR close? - Part of apache#11101. # Rationale for this change No benchmark calls `unshred_variant`, directly or through `variant_get`, so changes to this kernel can't be compared on the existing suite. apache#11106 is a current example: it changes how nested fallback values are written, and nothing measures that path. # What changes are included in this PR? Adds seven `unshred_variant` benchmarks to `variant_kernels`, each processing 8,192 rows. The cases are chosen so that a change to one path should not move the others. | Benchmark | Rows | What it isolates | ns/row | |---|---|---|---:| | `unshred_variant_primitive` | Int64, fully typed | Row loop and metadata validation | 41 | | `unshred_variant_object` | `{first, last, age}`, fully typed | Object construction with a small dictionary | 406 | | `unshred_variant_partial_object` | 5 of 15 fields typed, 10 leftover, one sorted 300-name dictionary shared by all rows | Merging typed and leftover fields, binary search name lookups | 3,354 | | `unshred_variant_partial_object_unsorted_metadata` | Same documents, unsorted dictionary | Linear scan name lookups | 18,020 | | `unshred_variant_nested_fallback` | Field shredded as Int64 holding an object 5 levels deep with 2 fields per object | Rebuilding a nested fallback value | 10,223 | | `unshred_variant_list` | `List<Float64>`, 0 to 100 elements per row | Per-element list cost | 775 | | `unshred_variant_list_of_objects` | 8 typed objects per row | Objects in lists, repeated name lookups within a row | 1,589 | Times are medians of 3 Criterion runs on one workstation, to show scale only. Left out on purpose: the unshredded fast path, because it is a constant-time clone, and other primitive types and metadata encodings, which stayed within about 12 ns and about 5% of these cases in ad hoc runs. The partial object schema and the JSON-to-variant setup move into small helpers shared with existing benchmarks, and the object fixture can now take its dictionary order. The existing benchmarks keep their names and workloads. # Are these changes tested? This is benchmark-only. As a check that the suite catches what it is for, applying the source changes from apache#11106 moves `unshred_variant_nested_fallback` from 10,223 to 18,917 ns per row (1.85x), while the other six cases stay between 0.99x and 1.03x. # Are there any significant user-facing changes? No, only benchmark code changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
|
@peterxcli I added a bench for Could you please update this branch 🙏 |
…-metadata Resolve the conflict with apache#12092, which removed `TopLevelRowSink`, and switch the tests from `StructArrayBuilder` to `StructArrayAssembler`, which moved to arrow-array in apache#10636. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
run benchmark unshred_variant |
This comment was marked as outdated.
This comment was marked as outdated.
|
run benchmark variant_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: variant_kernels Sharding factor: 1 (1 workers). Comparing fix/variant-missing-metadata (8f1adb8) to 1b42833 (merge-base) diff Run configurationResults will be posted when all workers finish. File an issue against this benchmark runner |
This comment was marked as outdated.
This comment was marked as outdated.
|
🤖 Benchmark completed (GKE) | trigger Target: variant_kernels Comparing fix/variant-missing-metadata (8f1adb8) to 1b42833 (merge-base) diff Run configurationDetailsPer-runner informationvariant_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-1ucnhyuy-1723d824-228s Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: CPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
Is the only one regressing due to nested structs child revalidation via iter_try() |
Each remaining row reaches a different conversion to the fallible append.
The removed rows (`{"a":null}`, nested, list, masked rows, and the
nested/list absent-field cases) failed on the same reverted conversions
as a kept row, or on none of them.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@peterxcli I took the liberty of trimming the tests to push this forward 🙏 |
sdf-jkl
left a comment
There was a problem hiding this comment.
Thank you @peterxcli this was much needed downstream
|
Thanks again @peterxcli 🙌 |
|
Thanks @sdf-jkl for driving this to completion 🚀 |
… and lists (apache#12430) # Which issue does this PR close? - Follow-up to apache#11106, which made `unshred_variant_nested_fallback` 1.85x slower on the benchmark runner. # Rationale for this change `VariantObject::iter_try` and `VariantList::iter_try` call `with_full_validation()` on every child, and `ValueBuilder::try_append_variant` then recurses into each child object or list and calls `iter_try` again. A value nested `d` levels deep is fully validated about `d` times. With apache#11106, `unshred_variant` takes this path for fallback values, even though it has already fully validated each value with `Variant::try_new_with_metadata`. Full validation of an object or list recursively validates all of its children, so every child of a validated value is already valid. The accessors build each child with only shallow checks, so the child loses that fact and gets validated again. This is the same problem apache#10879 fixed for metadata dictionary entries. # What changes are included in this PR? `VariantObject` and `VariantList` mark a child as fully validated when they build it from a fully validated parent. `with_full_validation` on such a child returns immediately, so `iter_try`, `try_field` and `try_get` no longer re-validate subtrees. Children of unvalidated parents are built and validated as before. This conflicts with apache#12309 from @cetra3, which rewrites the code that builds child values. The resolution adds the same one-line call where apache#12309 builds children, and I am happy to do it in whichever PR lands second. # Are these changes tested? `test_children_inherit_full_validation` checks that the fields and list elements of a validated value report `is_fully_validated()`, and that those of an unvalidated value do not. It fails if either the object or the list half of the change is removed. `unshred_variant_nested_fallback` from `variant_kernels` (local x86, `codegen-units=1`): | | time | |---|---| | before apache#11106 | 89.7 ms | | apache#11106 | 159.8 ms | | apache#11106 and this PR | 87.1 ms | Removing the `with_full_validation()` calls from both `iter_try` implementations entirely gives about the same time (88.8 ms), so the re-validation accounts for the whole regression. # Are there any significant user-facing changes? Children returned by the accessors of a fully validated `VariantObject` or `VariantList` (`field`, `get`, `iter` and their fallible versions) now report `is_fully_validated() == true`. They reported `false` before, although they were valid. No public API changes. # AI usage disclosure Claude Code helped find the cause, write the change and test, and run the benchmarks. I reviewed the change and the measurements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Which issue does this PR close?
Closes #11069.
unshred_variantpanics when a present shredded field name is missing from metadata.What changes are included in this PR?
Add
VariantBuilderExt::try_append_valueand propagate builder errors through unshredding, including nested objects and list elements.Are these changes tested?
Regression tests cover missing metadata names, absent fields, and parent nulls. Variant crate tests, formatting, and Clippy pass.
Are there any user-facing changes?
Missing metadata field names now produce
ArrowErrorinstead of a panic. Existingappend_valueAPIs remain available.