apache / apache/iceberg-python
IO: Consolidate PyArrow logic into io/pyarrow.py before decomposition
- Ngôn ngữ chính
- Python
- Star
- 1.1k
- Fork
- 581
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 78
Mô tả
## Summary
Before decomposing `pyiceberg/io/pyarrow.py` into focused submodules (#3737, #3738), we should consolidate PyArrow-specific logic that currently lives outside the module. This ensures all PyArrow calls route through a single boundary, making the subsequent split clean and enabling future engine substitution.
## Motivation
Per discussion in #3737, @rambleraptor noted that the first useful step is ensuring no PyArrow logic occurs outside `pyarrow.py`. Currently several modules import `pyarrow` directly and implement compute logic inline rather than delegating through `pyiceberg.io.pyarrow`.
When we later introduce a `ComputeEngine` protocol, any PyArrow logic outside the module boundary bypasses the protocol and prevents clean substitution.
## Audit
Grepped `pyiceberg/` (excluding `io/pyarrow.py` and tests) for runtime `import pyarrow` statements (both top-level and inline). Excluded `TYPE_CHECKING`-only imports since those have no runtime dependency.
| Location | What it does | Action |
|----------|-------------|--------|
| `table/upsert_util.py` | PyArrow table joins, group_by, compute, cast, take | **Absorb** |
| `table/inspect.py` | Builds pa.schema + pa.Table.from_pylist for metadata inspection | **TBD** |
| `transforms.py` | `pyarrow_transform()` dispatch on pa.Array/ChunkedArray | **TBD** |
| `table/__init__.py` | Entry points accept pa.Table, delegate to io.pyarrow | **Leave** |
| `table/deletion_vector.py` | Single pa.chunked_array() call | **Leave** |
| `catalog/__init__.py` | Delegates to io.pyarrow for schema conversion | **Leave** |
## Plan
One PR per absorption. Each is a pure refactor: move code into `io/pyarrow.py`, have the caller import from `pyiceberg.io.pyarrow` instead of `pyarrow` directly. No behavior change, all existing tests pass unchanged.
- [ ] PR A: Absorb `table/upsert_util.py` PyArrow logic
- [ ] PR B: `table/inspect.py` (pending discussion)
- [ ] PR C: `transforms.py` (pending discussion)
## Related
- #3737 - Decompose io/pyarrow.py into focused modules
- #3738 - Extract PyArrowFileIO (first decomposition step)
- #3715 / #3716 - Previous pluggable backend attempt (rejected as too large)
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách so sánh table/upsert_util.py với pyiceberg/io/pyarrow.py và xem lại thảo luận liên quan trong #3737. Trước tiên, hãy tập trung vào PR A; hoàn thành nghĩa là logic PyArrow của tiện ích upsert đi qua io/pyarrow.py, không thay đổi hành vi và tất cả các kiểm thử hiện có đều vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Tái cấu trúc
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100