apache / apache/iceberg-python
SqlCatalog table operations should filter on `iceberg_type`
- Vorherrschende Sprache
- Python
- Sterne
- 1.1k
- Forks
- 581
- Ø Merge
- 1 T. 17 Std.
- Gemergte PRs (30 T.)
- 78
Beschreibung
### Feature Request / Improvement
In #3263, the `iceberg_type` column was added to the SQLCatalog and filters it in `list_tables`, but the other table operations (i.e. load_table, drop_table, rename_table, commit_table) don't check it yet. That means a view row written by iceberg java or iceberg-rust can bleed in pythons SQLCatalog table operations.
Java's V1 catalog applies `WHERE (iceberg_type = 'TABLE' OR iceberg_type IS NULL)` everywhere ([JdbcUtil.java#L168](https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java#L168)). We should do the same.
Probably worth extracting a small helper since the predicate would now appear in ~5+ places.
Repro steps:
```python
catalog = SqlCatalog("test", uri="sqlite:///...", warehouse="...")
catalog.create_namespace("ns")
# bypass and sim java/rust writing a view row
with catalog.engine.connect() as conn:
conn.execute(text(
"INSERT INTO iceberg_tables VALUES "
"('test', 'ns', 'a_view', 's3://fake/m.json', NULL, 'VIEW')"
))
conn.commit()
catalog.drop_table(("ns", "a_view")) # Silently deletes the view row :/
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne in den Methoden für Tabellenoperationen von SqlCatalog, vergleiche deren Prädikate mit der bestehenden iceberg_type-Behandlung in list_tables aus #3263 und reproduziere das Problem mit dem bereitgestellten SQLite-Setup und der View-Zeile. Als erledigt gilt die Aufgabe, wenn load_table, drop_table, rename_table und commit_table Zeilen mit iceberg_type VIEW nicht mehr als Tabellen behandeln, während TABLE- und NULL-Zeilen weiterhin funktionieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python, sql
- Bereich
- databases
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 68/100