feat: add dictionary_columns to scan API for memory-efficient string reads#3234
Open
tanmayrauth wants to merge 1 commit intoapache:mainfrom
Open
feat: add dictionary_columns to scan API for memory-efficient string reads#3234tanmayrauth wants to merge 1 commit intoapache:mainfrom
tanmayrauth wants to merge 1 commit intoapache:mainfrom
Conversation
946d70a to
52b2070
Compare
52b2070 to
9fc3b0c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exposes
dictionary_columns: tuple[str, ...] | None = NoneonTable.scan()andDataScan, threading it through to PyArrow'sParquetFileFormatso that named columns are read asDictionaryArrayinstead of plainlarge_utf8. This dramatically reduces memory usage for high-cardinality repeated JSON/string columns (issue #3168) and addresses the general scan parameter extensibility request (issue #3170).Key implementation details:
dictionary_columnsis only passed for ParquetArrowScan.to_table()rebuilds the Arrow schema with dict types before the empty-table fast-path so schema is consistent regardless of row countDataScan.to_arrow_batch_reader()rebuildstarget_schemawith dict types to prevent.cast()from silently decoding DictionaryArray back to plain stringDataScan.__init__declares and stores the param soTableScan.update()(which usesinspect.signature) preserves it across scan copiesFixes #3168, closes #3170
Rationale for this change
Are these changes tested? Yes
Are there any user-facing changes? No