Skip to content

fix(variant): preserve nulls for missing shredded list indexes - #12224

Merged
sdf-jkl merged 2 commits into
apache:mainfrom
sdf-jkl:variant-get-shredded-list-null-11050
Nov 13, 2026
Merged

sdf-jkl merged 2 commits into
apache:mainfrom
sdf-jkl:variant-get-shredded-list-null-11050

Conversation

@sdf-jkl

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

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

This carries @emecii's fix from #11052, which was approved but has had no activity since October. The commit is unchanged and keeps their authorship, rebased onto current main.

An out-of-bounds list lookup and a present Variant null both produce null child columns after take. Without tracking index validity separately, shredded input turns missing list positions into valid Variant nulls, unlike unshredded input.

What changes are included in this PR?

  • Carry the list index validity mask through shredded path traversal (@emecii's commit).
  • Apply that mask to the output while preserving explicit Variant null elements as valid values.
  • Regression test distinguishing an empty list, an explicit null element, and a typed element.
  • When no row has the requested index in bounds, the path step is Missing and take is skipped. This addresses the all-out-of-bounds slowdown measured in fix(variant): preserve nulls for missing shredded list indexes #11052. value is not consulted because arrays are never stored there when typed_value is a list, which matches Spark (SparkShreddingUtils returns null for an out-of-bounds index without reading value).
  • For the same reason, the two existing no-match exits of the list index step (elements are not a struct, or elements hold no values) now also return Missing instead of falling back to value row by row. For valid data this changes no results, since value can only hold non-arrays there, which index to NULL.
  • A Missing path step with no as_type now returns an all-null VariantArray, as documented on GetOptions::as_type, instead of a NullArray.

Are these changes tested?

Yes. test_shredded_list_out_of_bounds_is_null distinguishes an empty list, an explicit null element, a typed element, and a non-list row, for both a mixed and an all-out-of-bounds index. The existing missing-path Variant output test now also runs without as_type.

variant_get_list_index_all_oob_int64_64_rows goes from 1.32 µs to 0.47 µs locally compared to #11052. The other variant_get_list_index benchmarks are within noise.

Are there any significant user-facing changes?

variant_get without as_type now returns an all-null VariantArray instead of a NullArray when the path cannot match a shredded column, for example a field that does not exist on a fully shredded object.

AI usage disclosure

The original change was written with OpenAI Codex (see #11052). Claude Code carried the commit over and drafted this description.

🤖 Generated with Claude Code

Co-authored-by: Yifan Chen [email protected]

emecii and others added 2 commits November 12, 2026 21:51
When no row has the requested index in bounds, the shredded list index
step returns Missing without calling take or reading value. Arrays are
never stored in value when typed_value is a list, so no row can match.

A Missing path step without as_type now returns an all-null VariantArray,
as documented on GetOptions::as_type, instead of a NullArray.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@boring-cyborg boring-cyborg Bot added the parquet-variant parquet-variant* crates label Nov 13, 2026
@sdf-jkl

sdf-jkl commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

run benchmark variant_kernels

env:
BENCH_FILTER: "^variant_get_list_index"

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_kernels

Sharding factor: 1 (1 workers).

Comparing variant-get-shredded-list-null-11050 (01cfe0e) to 275adb2 (merge-base) diff

Run configuration
run benchmark variant_kernels
env:
  BENCH_FILTER: ^variant_get_list_index
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 variant-get-shredded-list-null-11050 (01cfe0e) to 275adb2 (merge-base) diff

Run configuration
run benchmark variant_kernels
env:
  BENCH_FILTER: ^variant_get_list_index
shards: 1
Details
group                                           base                                   changed
-----                                           ----                                   -------
variant_get_list_index_all_oob_int64_64_rows    2.05  1772.1±45.59ns        ? ?/sec    1.00    864.1±8.57ns        ? ?/sec
variant_get_list_index_shredded                 1.00     45.3±1.32µs        ? ?/sec    1.04     47.1±1.50µs        ? ?/sec
variant_get_list_index_unshredded               1.01  1036.5±13.07µs        ? ?/sec    1.00  1023.1±13.86µs        ? ?/sec

Per-runner information
variant_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-lxiegy2m-5957d461-dftn

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

uname:

Linux bench-c6842421123-4885-nkhkx 6.12.105+ #1 SMP Sat Sep 19 07:55:25 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):                                  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
Resource Usage

base (merge-base)

Metric Value
Wall time 35.0s
Peak memory 373.8 MiB
Avg memory 23.8 MiB
CPU user 29.5s
CPU sys 0.2s
Peak spill 0 B

branch

Metric Value
Wall time 35.0s
Peak memory 429.6 MiB
Avg memory 27.3 MiB
CPU user 28.9s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl

sdf-jkl commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

FYI -- There's some stuff on top of the original @emecii changes

@sdf-jkl
sdf-jkl added this pull request to the merge queue Nov 13, 2026
@sdf-jkl

sdf-jkl commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Thanks @Jefffrey @Rich-T-kid @emecii 🙏

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 13, 2026
@sdf-jkl
sdf-jkl added this pull request to the merge queue Nov 13, 2026
Merged via the queue into apache:main with commit 4ea4d22 Nov 13, 2026
22 checks passed
@sdf-jkl
sdf-jkl deleted the variant-get-shredded-list-null-11050 branch November 13, 2026 05:54
@Jefffrey Jefffrey added the bug Squash those bugs label Nov 13, 2026
mbutrovich pushed a commit to mbutrovich/arrow-rs that referenced this pull request Nov 24, 2026
…pache#11504)

- Preserve SQL NULL for missing shredded object fields while retaining
explicit JSON nulls.
- Reuse apache#12224’s `path_nulls` and cover nested paths, fallback values,
empty objects, and sliced arrays.
- Closes apache#11191.

---------

Co-authored-by: Shatrughna Upadhyay <[email protected]>
Co-authored-by: Kosta Tarasov <[email protected]>
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.

[Variant] variant_get returns Variant null instead of SQL NULL for out-of-bounds access on shredded lists

5 participants