apache / apache/iceberg-python

SqlCatalog table operations should filter on `iceberg_type`

Aperta
#3,337 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
1.1k
Fork
581
Merge medio
1g 17h
PR unite (30g)
78

Descrizione

### 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 :/
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia nei metodi per le operazioni sulle tabelle di SqlCatalog, confronta i relativi predicati con la gestione esistente di iceberg_type in list_tables di #3263 e riproduci il problema con la configurazione SQLite e la riga della view fornite. Il lavoro è completato quando load_table, drop_table, rename_table e commit_table non trattano più come tabelle le righe con iceberg_type VIEW, mentre le righe TABLE e NULL continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, sql
Ambito
databases
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.