GayathriSrividya opened a new pull request, #3525:
URL: https://github.com/apache/iceberg-python/pull/3525

   closes #3337
   
   ## Summary
   
   Adds the `iceberg_type` column to the `IcebergTables` ORM model (also 
superseding #3263) and extends the type filter to **all** table operations, 
matching Java's `JdbcCatalog` behavior.
   
   ## Root cause
   
   PR #3263 proposed adding `iceberg_type` to `list_tables`, but was not yet 
merged. Meanwhile #3337 identified that even after that fix, `load_table`, 
`drop_table`, `rename_table`, and `commit_table` would still lack the filter. 
View rows written by iceberg-java or iceberg-rust can therefore bleed into 
Python's table operations.
   
   Java's JdbcCatalog applies `WHERE (iceberg_type = 'TABLE' OR iceberg_type IS 
NULL)` to every table lookup 
([JdbcUtil.java#L168](https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java#L168)).
   
   ## Changes
   
   ### pyiceberg/catalog/sql.py
   - Add `iceberg_type: Mapped[str | None]` column to `IcebergTables` model.
   - Add `ICEBERG_TABLE_TYPE = "TABLE"` constant.
   - Add idempotent `ALTER TABLE iceberg_tables ADD COLUMN iceberg_type` 
migration in `_ensure_tables_exist` (backward-compatible; catches 
`OperationalError`/`ProgrammingError` if column already exists).
   - Set `iceberg_type=ICEBERG_TABLE_TYPE` on all `IcebergTables` inserts: 
`create_table`, `register_table`, `commit_table` (new table path).
   - Apply `WHERE (iceberg_type = 'TABLE' OR iceberg_type IS NULL)` filter to: 
`load_table`, `drop_table`, `rename_table`, `commit_table`, `list_tables`.
   
   ### tests/catalog/test_sql.py
   - Add `TestIcebergTypeFilter` class with 5 regression tests:
     - `test_iceberg_type_set_on_create` — verifies new tables get 
`iceberg_type='TABLE'`
     - `test_list_tables_excludes_view_rows`
     - `test_load_table_ignores_view_rows`
     - `test_drop_table_ignores_view_rows`
     - `test_rename_table_ignores_view_rows`
   
   ## Validation
   - `make lint` ✓
   - `pytest tests/catalog/test_sql.py` → 17 passed ✓


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to