Repository navigation
fix(variant): reject duplicate object field names in shred_variant - #11351
Conversation
|
run benchmark variant_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: variant_kernels Sharding factor: 1 (1 workers). Comparing parquet-variant-compute-new (a3310ab) to 1d1607a (merge-base) diff Run configurationrun benchmark variant_kernels
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: variant_kernels Comparing parquet-variant-compute-new (a3310ab) to 1d1607a (merge-base) diff Run configurationrun benchmark variant_kernels
shards: 1
DetailsPer-runner informationvariant_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-1midrx00-a14d3a6f-nhtm Instance: c4a-highcpu-48 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
sdf-jkl
left a comment
There was a problem hiding this comment.
Thanks @Abhisheklearn12 LGTM 🙏
Sorry for taking a while to review
| let mut builder = value_builder.builder_ext(value.metadata()); | ||
| let mut object_builder = builder.try_new_object()?; | ||
| // Error on a repeated unshredded field instead of overwriting it | ||
| let mut object_builder = builder.try_new_object()?.with_validate_unique_fields(true); |
There was a problem hiding this comment.
Small pre-existing documentation nit:
the docs for ObjectBuilder::with_validate_unique_fields and VariantBuilder::with_validate_unique_fields still say duplicates cause ObjectBuilder::finish() to return an error.
The check actually happens during insertion, and finish() returns ().
|
Thanks @Abhisheklearn12 🚀 |
Which issue does this PR close?
Rationale for this change
When an object repeats a field name,
shred_variantappends both values to that field's builder. That field's column ends up one row longer than the others, and arrow-array panics. If the duplicate field is not shredded, there is no panic: only the last value is kept and the earlier ones are silently dropped.Variant::try_newrejects such objects, butshred_variantreads rows with shallow validation only, so they reach the shredder.What changes are included in this PR?
A repeated field name now returns
InvalidArgumentError("Duplicate field name: ..."), as the issue requests:seenscratch buffer. The issue's proposedHashSetfix predates perf(variant): resolve borrowed field names without searching the metadata dictionary #10882, which replaced the per-row set with this buffer.insert_bytesbecomestry_insert_bytes, so the error is returned instead of panicking.Valid input is unaffected: both checks fire only when a field name repeats within one object. Unshredded repeats are detected by field id, so an object whose dictionary is (invalidly) flagged sorted yet repeats a name still passes through unchanged, as before. Catching it would need a name-based check per row, like the per-row HashSet that #10882 removed for performance.
Are these changes tested?
Yes.
test_object_with_duplicate_field_names_errorscovers a duplicate referenced by the same field id and by two ids naming the same string, each with the field shredded and unshredded. The test fails if either half of the fix is removed.Are there any significant user-facing changes?
No API changes. An object with a repeated field name is invalid input; it now returns an error instead of panicking or returning
Okwith only the last value kept.