Anurag-S1ngh opened a new pull request, #4492:
URL: https://github.com/apache/iceberg-python/pull/4492

   # 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 from 
`to_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()` and `to_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 skipped
   - `pytest tests/ -m unit --ignore=tests/integration`: 4884 passed, 6 skipped
   - `ruff check` and `ruff format --check` pass
   - `ty check` reports nothing for the new methods; existing diagnostics are 
unchanged
   
   ## Are there any user-facing changes?
   
   `to_arrow_batch_reader()` now uses substantially less memory for large 
scans. It is sequential rather than parallel, so `to_table()` and `to_pandas()` 
remain the better choices when throughput matters more than bounded memory.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to