apache / apache/iceberg-python

SqlCatalog table operations should filter on `iceberg_type`

オープン
#3,337 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
1.1k
フォーク
581
平均マージ
1日 17時間
マージ済み PR(30日)
77

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

SqlCatalog のテーブル操作メソッドから始め、#3263 の list_tables にある既存の iceberg_type の処理とそれらの述語を比較し、提供された SQLite のセットアップと view の行で問題を再現します。load_table、drop_table、rename_table、commit_table が iceberg_type VIEW の行をテーブルとして扱わなくなり、TABLE と NULL の行は引き続き動作すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, sql
領域
databases
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。