Repository navigation
Conversation
21anaghar
force-pushed
the
fix/polars-arrow-zero-copy-ingestion
branch
3 times, most recently
from
November 30, 2026 22:12
67ee279 to
40a6109
Compare
…Data Interface support - Implement direct Polars native Arrow IPC streaming, eliminating intermediate pyarrow.Table conversion allocations. - Implement Arrow C Data & Stream interface loader in C++ ArrowLoader (initialize_c_data / initialize_c_stream). - Switch PyArrow serialization to RecordBatchStreamWriter. - Next step: large-scale streaming validation (10,000+ batch updates / high-frequency market tick testing). Signed-off-by: Anagha Ram <anagha.ram@ibm.com>
21anaghar
force-pushed
the
fix/polars-arrow-zero-copy-ingestion
branch
from
November 30, 2026 22:13
40a6109 to
3d66329
Compare
texodus
reviewed
Dec 1, 2026
texodus
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR.
Being "related to" an issue is not adequate, and this PR does not address either of the cited issues. Please also make sure to build the project and run the test suite locally before opening a PR (this change does not pass the python suite), it saves a considerable amount of time.
| // Direct Polars Arrow IPC stream serialization avoiding PyArrow conversion and memory duplication | ||
| let io = PyModule::import(py, "io")?; | ||
| let buffer = io.getattr("BytesIO")?.call0()?; | ||
| df.call_method1("write_ipc_stream", (&buffer,))?; |
Member
There was a problem hiding this comment.
write_ipc_stream and to_arrow are not same - this raises the compatibility level to "newest" by default, which Perspective's reader does not fully support yet (fails on utf8_view and categorical columns ingest). See test_table_polars_from_schema_str, arrow_loader.cpp convert_type
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.
Summary
This PR optimizes the Arrow ingestion path for Polars DataFrames/LazyFrames and PyArrow Tables in
perspective-python, eliminating intermediatepyarrow.Tableconversion copies and adding C Data Interface support inArrowLoader.Relates to #2729 and #1157.
Key Changes
Polars Ingestion (
polars.rs):df.to_arrow()withdf.write_ipc_stream()to avoid allocating an intermediatepyarrow.Tablein Python memory before serialization.__index_level_0__->index) and reordering are now handled directly in Polars prior to streaming.C++ ArrowLoader (
arrow_loader.h,arrow_loader.cpp):initialize_c_data(ArrowArray*, ArrowSchema*)andinitialize_c_stream(ArrowArrayStream*)usingarrow::ImportRecordBatchandarrow::ImportRecordBatchReader.ArrowLoaderto ingest Arrow C Data Interface pointers directly.PyArrow Serialization (
pyarrow.rs):RecordBatchFileWritertoRecordBatchStreamWriterto avoid writing unnecessary file footer metadata during streaming updates.Changes Overview
masterto_arrow()topyarrow.Tablewrite_ipc_stream()ArrowLoaderC ABI Supportconst uint8_t*)ArrowArray*/ArrowSchema*/ArrowArrayStream*RecordBatchFileWriterRecordBatchStreamWriterTesting & Next Steps
test_table_polars.py,test_table_arrow.py).