Skip to content

fix: read nested offsets of sliced arrays once when concatenating a native sort's payload - #7

Merged
msafonov merged 1 commit into
branch-1.1from
joom/1.1-fix-offsets-fit
Oct 9, 2026
Merged

msafonov merged 1 commit into
branch-1.1from
joom/1.1-fix-offsets-fit

Conversation

@msafonov

@msafonov msafonov commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Was stacked on #6. #6 is now merged into branch-1.1 and this PR is retargeted there, so it contains only its own commit.

Problem

On the night of 2026-10-09, 10 tasks of platform.mongo-uber-loader-daily failed on joom-1.1-4 in the native sort. All of them had wide nested Mongo rows (products, productVariants, parcels, trackings, orderJLShippingInfo, ...):

  • CometNativeException: assertion failed: end <= self.len() (9 tasks)
  • CometNativeException: range start index 17 out of range for slice of length 1 (platform_critical_jl-alerts_daily)

Stack: ArrayData::slice <- late_materialize::offsets_fit <- Gather::concatenate <- Gather::try_new (one task also went through ExternalSorter::sort_and_spill).

Cause

offsets_fit (added in 6975eba) walks ArrayData and applies the offset twice:

  • ArrayData::buffer::<i32>(0) already starts at data.offset(), but the code indexed it again with [offset..=offset + len].
  • ArrayData::slice of a struct already slices its children and keeps the offset, but the code sliced the children again by data.offset().

Top-level columns come from to_data() with offset 0, so they were fine. The panic needs a list, struct or map nested inside a list of a sliced input batch, which means value_offsets()[0] != 0 (for example, batches coming out of the coalescer). The existing test schema had no such nesting.

Fix

offsets_fit now walks typed arrays (as_list, as_map, as_struct, as_fixed_size_list). Their value offsets and columns already account for the slice. merge passes it the arrays directly.

Tests

  • offsets_fit_reads_a_list_nested_in_a_sliced_list: panicked before the fix with range start index 17 out of range for slice of length 1.
  • offsets_fit_reads_a_struct_nested_in_a_sliced_list: panicked before the fix with assertion failed: end <= self.len().
  • nested_list_offsets_that_would_overflow_are_not_concatenated: the i32 overflow guard still works under nesting.
  • sliced_nested_rows_match_the_reference: end to end through SortExec on sliced batches of list<struct<int, list<utf8>>> plus map<utf8, utf8>, both in memory and with a spill. It panicked before the fix and now matches the reference output.

Run locally (arm64 dev container):

  • vendored datafusion-physical-plan: 1755 passed
  • cargo test --workspace: 1918 passed, 0 failed
  • cargo fmt and cargo clippy --workspace -D warnings: clean
  • spotless:check and scalastyle: clean
  • WideRowSortFallbackSuite: 17/17
  • CometWindowExecSuite 71/71, CometFuzzTestSuite 45/45, CometExecSuite 155 passed / 2 canceled

🤖 Generated with Claude Code

…ative sort's payload

offsets_fit walked ArrayData and applied the offset twice: ArrayData::buffer
already starts at the array's offset, and ArrayData::slice of a struct
already slices its children while keeping the offset. A list, struct or map
nested in a sliced list therefore panicked with "range start index N out of
range for slice of length M" or "assertion failed: end <= self.len()" when
Gather concatenated the batches it sorts, which failed the mongo snapshot
loaders on joom-1.1-4.

Walk the typed arrays instead, whose value offsets and columns already
account for the slice, and cover lists of lists, lists of structs and maps
in sliced input batches, with and without a spill.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Oct 9, 2026
@msafonov
msafonov changed the base branch from joom/1.1-fix5 to branch-1.1 October 9, 2026 08:31
@msafonov

msafonov commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Local JVM suites (Spark 3.5, arm64 dev container, libcomet built from this commit): CometWindowExecSuite 71/71, CometFuzzTestSuite 45/45, CometExecSuite 155 succeeded / 0 failed / 2 canceled, WideRowSortFallbackSuite 17/17. spotless:check and scalastyle clean.

🤖 Generated with Claude Code

@msafonov
msafonov merged commit b536648 into branch-1.1 Oct 9, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant