Skip to content

Arrow: Release vectors decoded from dictionary encoded columns - #17742

Open
chiragkava wants to merge 1 commit into
apache:mainfrom
chiragkava:fix-dict-encoded-vector-leak
Open

Arrow: Release vectors decoded from dictionary encoded columns#17742
chiragkava wants to merge 1 commit into
apache:mainfrom
chiragkava:fix-dict-encoded-vector-leak

Conversation

@chiragkava

Copy link
Copy Markdown

Fixes #17722.

ColumnVector.getArrowVector() allocates a decoded vector per call for dictionary encoded columns and nothing released it (details in the issue). Following the ownership model of #17296, the decoded vector is now materialized once per batch and ArrowBatchReader releases it when the next read() invalidates the batch and on close(). Only dict-decoded vectors are released, so reuseContainers and the reader-owned holder vectors are untouched.
Spark/Flink don't use this code path.

Tested with a differential pair in TestArrowReader: the materializing test fails on main (33,280 bytes retained for 100 rows / 1 batch / 1 string column) and passes with the fix. the non-materializing control passes on both.

This contribution was developed with AI assistance Claude Code (Opus 5) and I have reviewed it

@github-actions github-actions Bot added the arrow label Aug 20, 2026

@anoopj anoopj left a comment

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.

#17738 is a duplicate of this PR. But this is one has the correct fix and looks good to me.

}

ColumnVector[] columnVectors = new ColumnVector[readers.length];
// release the decoded vectors the previous batch materialized, safe with reused containers

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.

This comment is not very readable.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrow: ColumnVector.getArrowVector() leaks direct memory for dictionary encoded columns

2 participants