Fix/sqlcatalog iceberg type filter#3709
Open
avison9 wants to merge 4 commits 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.
Rationale for this change
SqlCatalog'siceberg_tablestable can be shared with iceberg-java/iceberg-rust clients, whichstore both tables and views there using an
iceberg_typecolumn (TABLE/VIEW), filtering everylookup with
WHERE (iceberg_type = 'TABLE' OR iceberg_type IS NULL)(seeJdbcUtil.java#L168).PyIceberg had neither the column nor the filter, so a view row written by another implementation
would be silently treated as a table by
load_table,drop_table,rename_table, andcommit_table.Before:
After:
This PR builds on #3263 (cherry-picked here, unmerged, authored by @rchowell), which adds the
iceberg_typecolumn, an opt-in idempotent v0→v1 migration, and filterslist_tables. On top ofthat, it extracts a small
_iceberg_type_filter()helper (as suggested in #3337) and applies it toload_table,drop_table, andrename_table.commit_tableneeded no direct change since italready delegates its existence check to
load_table.Note on scope: a prior attempt at #3337 (#3525) tried to add the column and the filtering in one
PR, but was closed after review feedback preferred keeping #3263's column/migration approach
separate from the filtering logic. This PR keeps that separation by adopting #3263's commits as-is
and adding only the filtering on top.
Are these changes tested?
Yes, i added
test_load_table_ignores_view_rows,test_drop_table_ignores_view_rows, andtest_rename_table_ignores_view_rowsintests/catalog/test_sql.py, each inserting a rawVIEWrow and confirming the affected operation now raises
NoSuchTableErrorinstead of touching it.Verified all three fail without the fix. Full suite: 3796 passed, 0 failed.
Are there any user-facing changes?
Yes!
SqlCatalog.load_table,drop_table, andrename_tablenow correctly ignoreVIEWrowswritten by other Iceberg implementations sharing the same catalog table, instead of silently
reading, deleting, or renaming them. New optional
schema_versioncatalog property (from #3263)controls opt-in migration of existing v0 catalogs. Please apply the
changeloglabel.