Repository navigation
Core: Stream Arrow batch readers without read-ahead - #4492
Open
Anurag-S1ngh wants to merge 1 commit into
Open
Anurag-S1ngh wants to merge 1 commit into
Anurag-S1ngh wants to merge 1 commit into
Conversation
Add ArrowScan.to_record_batches_lazy and use it for to_arrow_batch_reader. Delete files are read per task only when reached, and tasks are no longer materialized through the executor. Closes apache#2407.
This branch has not been deployed
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.
Rationale for this change
to_arrow_batch_reader()is documented as the low-memory way to stream scan results, one RecordBatch at a time. In practice it sent every file scan task to the executor and materialized each task's batches into a list, so consuming one batch could read every file in the scan. Delete files were also read for all tasks up front.This adds
ArrowScan.to_record_batches_lazy()and uses it fromto_arrow_batch_reader(). The lazy path reads one task at a time in the calling thread, reads that task's delete files only when reached, and yields batches directly.to_table()andto_pandas()keep the existing threaded eager path.Closes #2407.
Are these changes tested?
Yes. Added a counting FileIO regression test proving that consuming the first batch opens only the first data file, plus a test that compares rows, ordering, and limit behavior between the lazy and eager paths.
pytest tests/io/test_pyarrow.py tests/table/test_init.py -m unit: 442 passed, 1 skippedpytest tests/ -m unit --ignore=tests/integration: 4884 passed, 6 skippedruff checkandruff format --checkpassty checkreports nothing for the new methods; existing diagnostics are unchangedAre there any user-facing changes?
to_arrow_batch_reader()now uses substantially less memory for large scans. It is sequential rather than parallel, soto_table()andto_pandas()remain the better choices when throughput matters more than bounded memory.