Repository navigation
fix(arrow): handle dense union slices and empty validation - #1385
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, clear diagnosis and a minimal fix. RawTypeCodes() runs to the end of the backing buffer, so limiting it to arr.Len() is right, and it also stops per-child lengths being computed from type codes outside the slice. I confirmed the new test fails without the fix: putting back only the old line fails exactly the dense-union middle-slice cases for List and LargeList, over both file and stream. The full arrow/ipc suite passes with it.
One small tidy-up inline before this lands; happy to approve once it's in.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. After you've
addressed the points above and pushed an update, an Apache Arrow
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.
zeroshade
left a comment
There was a problem hiding this comment.
Thanks for switching to array.ValidateFull, and nice catch on what it turned up: union.ValidateFull crashed on an empty dense union with no offsets buffer, and skipping the offset checks when the array is empty is right. Two small follow-ups:
- A direct test in
arrow/array/union_test.go(emptyDenseUnion, nil offsets buffer,ValidateFull()returns nil) would cover that fix on its own rather than only through the IPC round-trip. - Please mention the
arrow/arraychange in the PR description.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The findings
below are observations, not blockers; an Apache Arrow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, the direct ValidateFull test is exactly what I was after (it fails without the length > 0 check), and the description now covers both fixes. LGTM.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.
Rationale for this change
Writing a middle slice of a List or LargeList containing dense unions fails even when the input is valid. The stream writer returns an index-out-of-range error, and the file writer panics.
RawTypeCodes()includes the backing buffer's remaining entries, while the rebased output buffer holds only the logical slice length.Using the exported
array.ValidateFullin the regression also exposes an empty-array issue: an empty dense-union child decoded from IPC can have no value-offset buffer, but union validation unconditionally accesses that buffer.What changes are included in this PR?
arr.Len()type codes.array.ValidateFullhelper.arrow/array/union.go, run per-value dense offset validation only when the union has values. Child-type checks and nonempty offset validation remain unchanged.TestDenseUnionValidateEmptyregression inarrow/array/union_test.gofor an empty dense union with a nil value-offset buffer.Are these changes tested?
On Linux amd64 with Go 1.27.2:
go test ./arrow/array ./arrow/ipc -count=1passes.go vet ./arrow/array ./arrow/ipcpasses.Are there any user-facing changes?
Valid middle slices containing dense unions can be written and read back through IPC, and full validation handles empty decoded dense unions. No public API changes.
AI assistance: Codex generated the patch, regression test, and this description, and ran the recorded checks.