Skip to content

[Variant] Add VariantBuilder values check#10016

Open
sdf-jkl wants to merge 7 commits into
apache:mainfrom
sdf-jkl:variantbuilder-count-check
Open

[Variant] Add VariantBuilder values check#10016
sdf-jkl wants to merge 7 commits into
apache:mainfrom
sdf-jkl:variantbuilder-count-check

Conversation

@sdf-jkl

@sdf-jkl sdf-jkl commented May 25, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

  • (Single) VariantBuilder accepts 0/1+ values on finish.

What changes are included in this PR?

  • Add only 1 value validation for VariantBuilder
  • Move try_new_list/try_new_object to VariantBuilder
  • Replaced VariantBuilder with WritableMetadataBuilder in tests that only build metadata.

Are these changes tested?

  • Yes, existing unit tests pass.
  • Ran benchmarks locally and added some [#inline]

Are there any user-facing changes?

@github-actions github-actions Bot added the parquet-variant parquet-variant* crates label May 25, 2026
@sdf-jkl sdf-jkl marked this pull request as ready for review May 28, 2026 22:09
@sdf-jkl

sdf-jkl commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@alamb @scovich please take a look

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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 @sdf-jkl

fyi @scovich and @klion26

@sdf-jkl

sdf-jkl commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@alamb could you run some benchmarks?

#9791 (comment)

run benchmarks variant_builder variant_kernels variant_validation

@alamb

alamb commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

run benchmarks variant_builder variant_kernels variant_validation

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4662479980-508-f6l2k 6.12.68+ #1 SMP Sat May 2 07:49:07 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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

Comparing variantbuilder-count-check (f372e3a) to 1377761 (merge-base) diff
BENCH_NAME=variant_builder
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_builder
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4662479980-510-mvmlz 6.12.68+ #1 SMP Sat May 2 07:49:07 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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

Comparing variantbuilder-count-check (f372e3a) to 1377761 (merge-base) diff
BENCH_NAME=variant_validation
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_validation
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4662479980-509-4msnv 6.12.68+ #1 SMP Sat May 2 07:49:07 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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

Comparing variantbuilder-count-check (f372e3a) to 1377761 (merge-base) diff
BENCH_NAME=variant_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_kernels
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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
Details

group                               main                                   variantbuilder-count-check
-----                               ----                                   --------------------------
bench_validate_complex_object       1.00    182.7±5.36µs        ? ?/sec    1.00    182.1±5.20µs        ? ?/sec
bench_validate_large_nested_list    1.00     19.2±0.46ms        ? ?/sec    1.00     19.3±0.45ms        ? ?/sec
bench_validate_large_object         1.00     52.2±1.12ms        ? ?/sec    1.00     52.2±1.09ms        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 30.0s
Peak memory 12.5 MiB
Avg memory 8.1 MiB
CPU user 27.4s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 30.0s
Peak memory 12.5 MiB
Avg memory 7.8 MiB
CPU user 27.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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
Details

group                                       main                                   variantbuilder-count-check
-----                                       ----                                   --------------------------
bench_extend_metadata_builder               1.00     21.4±0.09ms        ? ?/sec    1.00     21.4±0.06ms        ? ?/sec
bench_object_field_names_reverse_order      1.10     13.4±0.38ms        ? ?/sec    1.00     12.2±0.10ms        ? ?/sec
bench_object_list_partially_same_schema     1.00  1057.7±13.57µs        ? ?/sec    1.00  1054.3±14.47µs        ? ?/sec
bench_object_list_same_schema               1.00     22.6±0.10ms        ? ?/sec    1.00     22.7±0.45ms        ? ?/sec
bench_object_list_unknown_schema            1.00     11.2±0.04ms        ? ?/sec    1.00     11.1±0.04ms        ? ?/sec
bench_object_partially_same_schema          1.00      2.7±0.01ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
bench_object_same_schema                    1.00     32.4±0.08ms        ? ?/sec    1.07     34.6±0.05ms        ? ?/sec
bench_object_unknown_schema                 1.00     13.4±0.04ms        ? ?/sec    1.00     13.4±0.12ms        ? ?/sec
iteration/unvalidated_fallible_iteration    1.00      2.0±0.00ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
iteration/validated_iteration               1.02     39.0±0.48µs        ? ?/sec    1.00     38.1±0.73µs        ? ?/sec
validation/unvalidated_construction         1.02      4.4±0.04µs        ? ?/sec    1.00      4.4±0.03µs        ? ?/sec
validation/validated_construction           1.00     64.4±0.56µs        ? ?/sec    1.00     64.6±0.93µs        ? ?/sec
validation/validation_cost                  1.00     56.9±0.46µs        ? ?/sec    1.00     56.9±0.46µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 140.0s
Peak memory 53.9 MiB
Avg memory 16.5 MiB
CPU user 131.9s
CPU sys 1.8s
Peak spill 0 B

branch

Metric Value
Wall time 135.0s
Peak memory 54.0 MiB
Avg memory 17.0 MiB
CPU user 129.8s
CPU sys 1.4s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
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:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
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
Details

group                                                                                             main                                   variantbuilder-count-check
-----                                                                                             ----                                   --------------------------
batch_json_string_to_variant json_list 8k string                                                  1.00     22.1±0.23ms        ? ?/sec    1.01     22.5±0.19ms        ? ?/sec
batch_json_string_to_variant object - 1 depth(100 fields) random_json(2436 bytes per document)    1.00    153.7±0.78ms        ? ?/sec    1.00    153.3±0.45ms        ? ?/sec
batch_json_string_to_variant object - 1 depth(200 fields) random_json(4871 bytes per document)    1.01    324.5±1.43ms        ? ?/sec    1.00    321.4±1.03ms        ? ?/sec
batch_json_string_to_variant random_json(2633 bytes per document)                                 1.00    228.3±0.91ms        ? ?/sec    1.00    227.4±0.52ms        ? ?/sec
batch_json_string_to_variant repeated_struct 8k string                                            1.01      6.5±0.07ms        ? ?/sec    1.00      6.5±0.04ms        ? ?/sec
variant_get_primitive                                                                             1.00    634.8±5.34ns        ? ?/sec    1.00    632.8±4.16ns        ? ?/sec
variant_get_shredded_utf8                                                                         1.01    635.1±3.99ns        ? ?/sec    1.00    628.9±3.61ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 160.0s
Peak memory 445.3 MiB
Avg memory 203.9 MiB
CPU user 151.6s
CPU sys 3.0s
Peak spill 0 B

branch

Metric Value
Wall time 155.0s
Peak memory 443.7 MiB
Avg memory 211.8 MiB
CPU user 150.8s
CPU sys 2.4s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl

sdf-jkl commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

everything looks fine other than -

bench_object_same_schema                    1.00     32.4±0.08ms        ? ?/sec    1.07     34.6±0.05ms        ? ?/sec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] VariantBuilder (wrongly?) accepts 0+ variant values

3 participants