IO: Extract PyArrowFileIO into dedicated module - #3738
Conversation
Move PyArrowFile, PyArrowFileIO, PyArrowLocalFileSystem and their helpers (_cached_resolve_s3_region, _import_retry_strategy) into pyiceberg/io/_pyarrow_fileio.py. The original pyiceberg/io/pyarrow.py re-exports all public names for full backward compatibility. This is the first step toward decomposing the 3100+ line pyarrow.py monolith into focused modules by concern, enabling future pluggable compute engines.
|
Given that #3737 plans several PyArrow-specific extractions, should we first convert |
|
Is this really needed? I'm not sure I find this an improvement, since I'd now have to go back and forth between two highly coupled files. |
Hi @abnobdoss, that's a good idea, a
Hi @Fokko, I agree that on its own, this extraction doesn't add much, Would a single PR that converts pyarrow.py into a package (as @abnobdoss suggests) and splits all concerns at once be more palatable? This current direction is based on conversations (recently with @kevinjqliu, @rambleraptor, and others previously) during the past two Python sync calls. It started with #3554, then #3715 / #3716 which has been superseded by #3737 and this PR. |
Summary
Extract
PyArrowFile,PyArrowFileIO,PyArrowLocalFileSystemand their helper functions into a newpyiceberg/io/_pyarrow_fileio.pymodule. The originalpyiceberg/io/pyarrow.pyre-exports all public names for full backward compatibility.This is the first step toward decomposing the 3,100+ line
pyarrow.pymonolith into focused modules by concern (tracked in #3737).Changes
pyiceberg/io/_pyarrow_fileio.py(584 lines) containing the FileIO implementationpyiceberg/io/pyarrow.py(-537 lines) replaced inline definitions with re-exportspyarrow.pythat were only needed by the FileIO sectionWhat stays the same
from pyiceberg.io.pyarrow import PyArrowFileIOimports continue to workPyArrowFileIOworks unchangedWhy
pyarrow.pyhandles 6 unrelated concerns in one file. The FileIO concern (filesystem abstraction for S3/GCS/Azure/HDFS/local) has zero coupling to schema conversion, expression translation, or statistics collection. Extracting it:Testing
Full unit test suite passes: 3803 passed, 3 skipped, 0 failures, 0 errors
(Windows local testing requires #3721 + #3722 applied on top; Linux CI should pass without them.)