iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Hive: dropTable silently drops an Iceberg view

Open thswlsqls opened this issue 4 months ago • 1 comments

Apache Iceberg version main @ 8550723a7

Query engine None — the bug is in HiveCatalog and is engine-agnostic.

Please describe the bug HiveCatalog.dropTable(identifier, false) does not check whether the identifier refers to an Iceberg view, so it silently drops the view and returns true (HiveCatalog.java line 240-289). The only view check is ops.current(), which sits inside the if (purge) branch, so purge=false reaches client.dropTable(...) unvalidated. HMS drop_table does not distinguish tables from views.

This breaks the Catalog.dropTable contract: "true if the table was dropped, false if the table did not exist" (api/.../catalog/Catalog.java line 305). A view is not a table.

It is inconsistent within the class too: tableExists(viewId) returns false, yet dropTable(viewId, false) drops that view. registerTable (line 943-949) and both builders already guard against table/view confusion; dropTable is the only path missing it.

InMemoryCatalog, JdbcCatalog, and REST already return false here; HiveCatalog is the only catalog affected.

Steps to reproduce

  1. Create an Iceberg view v via HiveCatalog.
  2. Call catalog.dropTable(v, false).

Expected: returns false, view survives. Actual: returns true, the view is gone.

With purge=true the same call instead propagates NoSuchTableException, so behavior splits on the purge flag.

Additional context N/A

thswlsqls avatar Jul 17 '26 07:07 thswlsqls

#17279 by @thswlsqls was moved to draft in July, closed by the stale bot in August without a review, and its branch was deleted in September. @thswlsqls, if you'd like to continue it, I'll step aside; otherwise I'd like to pick this up and credit your work. The plan is to have HiveCatalog.dropTable return false for an Iceberg view, for both purge values, using the same viewExists check that registerTable already uses.

binarybrain-009 avatar Oct 29 '26 14:10 binarybrain-009