Skip to content

fix(variant): reject duplicate object field names in shred_variant - #11351

Merged
sdf-jkl merged 2 commits into
apache:mainfrom
Abhisheklearn12:parquet-variant-compute-new
Oct 15, 2026
Merged

sdf-jkl merged 2 commits into
apache:mainfrom
Abhisheklearn12:parquet-variant-compute-new

Conversation

@Abhisheklearn12

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

When an object repeats a field name, shred_variant appends 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_new rejects such objects, but shred_variant reads 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:

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_errors covers 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 Ok with only the last value kept.

@sdf-jkl

sdf-jkl commented Oct 9, 2026

Copy link
Copy Markdown
Member

run benchmark variant_kernels

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_kernels

Sharding factor: 1 (1 workers).

Comparing parquet-variant-compute-new (a3310ab) to 1d1607a (merge-base) diff

Run configuration
run benchmark variant_kernels
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: variant_kernels

Comparing parquet-variant-compute-new (a3310ab) to 1d1607a (merge-base) diff

Run configuration
run benchmark variant_kernels
shards: 1
Details
group                                                                                             base                                   changed
-----                                                                                             ----                                   -------
batch_json_string_to_variant json_list 8k string                                                  1.00     19.4±0.17ms        ? ?/sec    1.00     19.5±0.07ms        ? ?/sec
batch_json_string_to_variant object - 1 depth(100 fields) random_json(2436 bytes per document)    1.00    146.5±0.40ms        ? ?/sec    1.00    146.6±0.24ms        ? ?/sec
batch_json_string_to_variant object - 1 depth(200 fields) random_json(4871 bytes per document)    1.00    310.0±0.99ms        ? ?/sec    1.00    309.8±1.03ms        ? ?/sec
batch_json_string_to_variant random_json(2633 bytes per document)                                 1.00    220.6±1.12ms        ? ?/sec    1.00    219.5±0.38ms        ? ?/sec
batch_json_string_to_variant repeated_struct 8k string                                            1.00      6.2±0.05ms        ? ?/sec    1.00      6.2±0.02ms        ? ?/sec
shred_variant_partial_object_8k_rows                                                              1.00     20.7±0.08ms        ? ?/sec    1.02     21.2±0.33ms        ? ?/sec
shred_variant_unmatched_object_8k_rows                                                            1.00     25.9±0.14ms        ? ?/sec    1.03     26.8±0.52ms        ? ?/sec
variant_array_builder_build_262k_small_values                                                     1.00      2.9±0.12ms        ? ?/sec    1.01      2.9±0.14ms        ? ?/sec
variant_get_binary_from_string                                                                    1.03   496.9±26.72µs        ? ?/sec    1.00    480.9±0.73µs        ? ?/sec
variant_get_binary_from_unshredded_binary                                                         1.04   481.0±31.52µs        ? ?/sec    1.00    461.0±2.90µs        ? ?/sec
variant_get_list_index_all_oob_int64_64_rows                                                      1.00  1772.8±43.46ns        ? ?/sec    1.00  1775.1±42.91ns        ? ?/sec
variant_get_list_index_shredded                                                                   1.01     46.0±1.76µs        ? ?/sec    1.00     45.5±1.54µs        ? ?/sec
variant_get_list_index_unshredded                                                                 1.05  1041.8±72.40µs        ? ?/sec    1.00   991.7±12.29µs        ? ?/sec
variant_get_primitive                                                                             1.00    573.0±4.82ns        ? ?/sec    1.00    571.6±6.76ns        ? ?/sec
variant_get_shredded_utf8                                                                         1.00    706.2±4.40ns        ? ?/sec    1.03    724.5±5.38ns        ? ?/sec
variant_get_unshredded_object_path_262k_rows                                                      1.04     38.6±2.05ms        ? ?/sec    1.00     37.2±0.48ms        ? ?/sec
variant_get_utf8_from_date                                                                        1.00    571.7±7.78µs        ? ?/sec    1.00    569.5±5.13µs        ? ?/sec
variant_get_utf8_from_decimal                                                                     1.01   479.6±14.72µs        ? ?/sec    1.00    473.1±6.21µs        ? ?/sec
variant_get_utf8_from_float                                                                       1.02   451.0±17.98µs        ? ?/sec    1.00    444.1±1.22µs        ? ?/sec
variant_get_utf8_from_int                                                                         1.02   451.7±17.73µs        ? ?/sec    1.00    444.9±1.17µs        ? ?/sec
variant_get_utf8_from_list                                                                        1.07   680.3±67.18µs        ? ?/sec    1.00   637.7±10.21µs        ? ?/sec
variant_get_utf8_from_map_in_list                                                                 1.05   706.0±63.57µs        ? ?/sec    1.00   670.6±11.94µs        ? ?/sec
variant_get_utf8_from_time                                                                        1.00    787.1±6.42µs        ? ?/sec    1.01    795.8±3.05µs        ? ?/sec
variant_get_utf8_from_timestamp_with_timezone                                                     1.02   581.8±15.41µs        ? ?/sec    1.00    570.1±3.02µs        ? ?/sec
variant_get_utf8_from_timestamp_without_timezone                                                  1.02   583.0±15.38µs        ? ?/sec    1.00    571.5±2.99µs        ? ?/sec
variant_get_utf8_from_unshredded_string                                                           1.04   510.9±27.84µs        ? ?/sec    1.00    493.1±1.20µs        ? ?/sec

Per-runner information
variant_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-1midrx00-a14d3a6f-nhtm

Instance: c4a-highcpu-48 (12 vCPU / 65 GiB)

uname:

Linux bench-c6090548452-3263-r9j26 6.12.94+ #1 SMP Fri Aug 21 08:00:16 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_kernels
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  48
On-line CPU(s) list:                     0-47
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     48
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               3 MiB (48 instances)
L1i cache:                               3 MiB (48 instances)
L2 cache:                                96 MiB (48 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-47
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Resource Usage

base (merge-base)

Metric Value
Wall time 365.1s
Peak memory 447.1 MiB
Avg memory 228.2 MiB
CPU user 352.8s
CPU sys 6.4s
Peak spill 0 B

branch

Metric Value
Wall time 355.1s
Peak memory 447.0 MiB
Avg memory 230.4 MiB
CPU user 345.0s
CPU sys 6.4s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 ().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hi @sdf-jkl, done in 503ad42, thanks :)

@sdf-jkl
sdf-jkl enabled auto-merge October 15, 2026 17:03
@sdf-jkl

sdf-jkl commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thanks @Abhisheklearn12 🚀

@sdf-jkl
sdf-jkl added this pull request to the merge queue Oct 15, 2026
Merged via the queue into apache:main with commit fedfd0d Oct 15, 2026
26 checks passed
@Jefffrey Jefffrey added the bug Squash those bugs label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Squash those bugs parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet-variant-compute: shred_variant panics on an object with duplicate field names

4 participants