apache / apache/iceberg-python

IO: Consolidate PyArrow logic into io/pyarrow.py before decomposition

Ouverte
#3,812 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
1.1k
Forks
581
Merge moyen
1 j 17 h
PR mergées (30 j)
78

Description

## 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)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par comparer table/upsert_util.py avec pyiceberg/io/pyarrow.py et examiner la discussion associée dans #3737. Concentrez-vous d’abord sur PR A ; cela signifie que la logique PyArrow de l’utilitaire d’upsert passe par io/pyarrow.py, sans changement de comportement et avec tous les tests existants qui passent.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
backend
Type d'issue
Refactorisation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
55/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.