Skip to content

Hive: Do not drop an Iceberg view via dropTable#17279

Draft
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/hive-droptable-view-guard
Draft

Hive: Do not drop an Iceberg view via dropTable#17279
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/hive-droptable-view-guard

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Closes #17278

Summary

  • HiveCatalog.dropTable(identifier, false) silently drops an Iceberg view and returns true: the only view check (ops.current()) is inside the if (purge) branch, and HMS drop_table does not distinguish tables from views. This breaks the Catalog.dropTable contract ("false if the table did not exist") and contradicts tableExists(viewId).
  • Adds a viewExists guard at the entry point, reusing registerTable's check (line 943-949); dropTable was the only path missing it.
  • purge=true also changes: returns false instead of propagating NoSuchTableException. Intentional — the guard is outside the purge branch, and the method already maps that exception to false (line 278-280).
  • Iceberg views only — non-Iceberg VIRTUAL_VIEWs are still dropped (out of scope).
  • Costs one extra HMS getTable, a tradeoff registerTable accepts.
  • InMemoryCatalog, JdbcCatalog, and REST already return false here; Hive diverges only because HMS keeps tables and views in one namespace. NoSuchTableException is the alternative, but false matches the Javadoc and every sibling.

Testing done

  • Added TestHiveViewCatalog#dropTableShouldNotDropIcebergView, asserting the view survives. Fails on main (returns true, view dropped), passes here.
  • ./gradlew :iceberg-hive-metastore:check — 309 tests passed.
  • Not a REVAPI module; signatures unchanged.

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
@github-actions github-actions Bot added the hive label Jul 17, 2026
@thswlsqls
thswlsqls marked this pull request as draft July 17, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hive: dropTable silently drops an Iceberg view

1 participant