fix: add iceberg_type column and filter all SqlCatalog table operations#3525
Open
GayathriSrividya wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #3337
Summary
Adds the
iceberg_typecolumn to theIcebergTablesORM model (also superseding #3263) and extends the type filter to all table operations, matching Java'sJdbcCatalogbehavior.Root cause
PR #3263 proposed adding
iceberg_typetolist_tables, but was not yet merged. Meanwhile #3337 identified that even after that fix,load_table,drop_table,rename_table, andcommit_tablewould 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).Changes
pyiceberg/catalog/sql.py
iceberg_type: Mapped[str | None]column toIcebergTablesmodel.ICEBERG_TABLE_TYPE = "TABLE"constant.ALTER TABLE iceberg_tables ADD COLUMN iceberg_typemigration in_ensure_tables_exist(backward-compatible; catchesOperationalError/ProgrammingErrorif column already exists).iceberg_type=ICEBERG_TABLE_TYPEon allIcebergTablesinserts:create_table,register_table,commit_table(new table path).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
TestIcebergTypeFilterclass with 5 regression tests:test_iceberg_type_set_on_create— verifies new tables geticeberg_type='TABLE'test_list_tables_excludes_view_rowstest_load_table_ignores_view_rowstest_drop_table_ignores_view_rowstest_rename_table_ignores_view_rowsValidation
make lint✓pytest tests/catalog/test_sql.py→ 17 passed ✓