Skip to content

GH-200: Keep registered type count when transferring a DenseUnionVector - #1381

Open
sharanggupta wants to merge 2 commits into
apache:mainfrom
sharanggupta:GH-200-dense-union-transfer-type-ids
Open

sharanggupta wants to merge 2 commits into
apache:mainfrom
sharanggupta:GH-200-dense-union-transfer-type-ids

Conversation

@sharanggupta

@sharanggupta sharanggupta commented Oct 21, 2026 •

Copy link
Copy Markdown

What's Changed

DenseUnionVector's transfer pair copies the type fields and type map into the target but leaves the target's nextTypeId at 0. The target then acts as if no types are registered: transferring it again creates no child transfer pairs, and its values read back as null.

This copies nextTypeId when the transfer pairs are created, so both transfer() and splitAndTransfer() leave the target with the source's registered types.

A parameterized test in TestSplitAndTransfer covers 18 vector kinds. For each, it transfers a populated vector (or splits and transfers it), transfers the result again, and compares it with the original using VectorEqualsVisitor. Without the fix, only the DenseUnionVector cases fail (expected [5, true, 7] but was [null, null, null]). mvn -pl vector -am test with TestSplitAndTransfer and TestDenseUnionVector passes, as does spotless:check.

Closes #200.

…onVector

DenseUnionVector's transfer pair copied the type fields and type map
into the target vector but left the target's nextTypeId at zero. The
target therefore behaved as if no types were registered: transferring
it again created no child transfer pairs and produced a vector whose
values read back as null.

Copy nextTypeId alongside the other type metadata when the transfer
pairs are created, so both transfer() and splitAndTransfer() leave the
target with the same registered types as the source.

Closes apache#200.
@github-actions

Copy link
Copy Markdown

Thank you for opening a pull request!

Please label the PR with one or more of:

  • bug-fix
  • chore
  • dependencies
  • documentation
  • enhancement

Also, add the 'breaking-change' label if appropriate.

See CONTRIBUTING.md for details.

@sharanggupta

Copy link
Copy Markdown
Author

The only failing check is "Ensure PR format", which needs a label. I don't have permission to add one; this is a bug-fix for #200.

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Oct 22, 2026
@lidavidm
lidavidm requested a balanced review from Copilot October 22, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

I think we should parameterize this test and test all types, ideally, instead of playing whack-a-mole. Or do other vectors have equivalent tests? (If so, I wonder if we could try and factor out common behavioral tests for vectors, instead of scattering them across different test classes)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good idea. Done in f41e9a8: I replaced the two DenseUnionVector-only tests with a parameterized test in TestSplitAndTransfer, where the transfer tests for the other vector kinds already live. For 18 kinds, it transfers a populated vector (or splits and transfers it), transfers the result again, and compares it with the original using VectorEqualsVisitor. The kinds are the fixed-width, variable-width and view vectors, fixed-size binary, the list, list-view and fixed-size list vectors, map, struct, union and dense union.

To answer the other question: without the fix, only the DenseUnionVector cases fail (expected [5, true, 7] but was [null, null, null]). The other 17 kinds already keep their values through a second transfer, so DenseUnionVector was the only one missing state there.

Factoring the other per-vector behavioural tests into shared parameterized tests looks worthwhile, but it touches many test classes, so I've kept it out of this PR. I can open an issue for it if that's useful.

Replace the two DenseUnionVector-only tests with a parameterized test in
TestSplitAndTransfer. For 18 vector kinds it transfers, or splits and
transfers, a populated vector, transfers the result again, and compares
it with the original using VectorEqualsVisitor. Without the fix only the
DenseUnionVector cases fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DenseUnionVector is not transferred correctly

3 participants