Hive: Do not drop an Iceberg view via dropTable#17279
Draft
thswlsqls wants to merge 1 commit into
Draft
Conversation
HiveCatalog.dropTable(identifier, false) did not check whether the identifier referred to an Iceberg view, so it dropped the view and returned true. The only view check, ops.current(), sits inside the if (purge) branch, and HMS drop_table does not distinguish tables from views. This broke the Catalog.dropTable contract, which documents "false if the table did not exist", and contradicted tableExists(), which already returns false for a view. registerTable() and both builders guard against table/view confusion; dropTable was the only path missing it. Add a viewExists() guard at the entry point, outside the purge branch, so purge=true and purge=false behave the same. purge=true now returns false instead of propagating NoSuchTableException. Generated-by: Claude Code
thswlsqls
marked this pull request as draft
July 17, 2026 11:16
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 #17278
Summary
HiveCatalog.dropTable(identifier, false)silently drops an Iceberg view and returnstrue: the only view check (ops.current()) is inside theif (purge)branch, and HMSdrop_tabledoes not distinguish tables from views. This breaks theCatalog.dropTablecontract ("false if the table did not exist") and contradictstableExists(viewId).viewExistsguard at the entry point, reusingregisterTable's check (line 943-949);dropTablewas the only path missing it.purge=truealso changes: returnsfalseinstead of propagatingNoSuchTableException. Intentional — the guard is outside thepurgebranch, and the method already maps that exception tofalse(line 278-280).VIRTUAL_VIEWs are still dropped (out of scope).getTable, a tradeoffregisterTableaccepts.InMemoryCatalog,JdbcCatalog, and REST already returnfalsehere; Hive diverges only because HMS keeps tables and views in one namespace.NoSuchTableExceptionis the alternative, butfalsematches the Javadoc and every sibling.Testing done
TestHiveViewCatalog#dropTableShouldNotDropIcebergView, asserting the view survives. Fails onmain(returnstrue, view dropped), passes here../gradlew :iceberg-hive-metastore:check— 309 tests passed.