close
Skip to content

Replace exception-driven view detection in Hive and Iceberg metadata layers#29231

Open
laserninja wants to merge 1 commit intotrinodb:masterfrom
laserninja:fix/29163-replace-exception-driven-view-detection
Open

Replace exception-driven view detection in Hive and Iceberg metadata layers#29231
laserninja wants to merge 1 commit intotrinodb:masterfrom
laserninja:fix/29163-replace-exception-driven-view-detection

Conversation

@laserninja
Copy link
Copy Markdown
Contributor

@laserninja laserninja commented Apr 24, 2026

Description

Move view/materialized-view detection from getRefreshedLocation() to loadTable() in both TrinoHiveCatalog and TrinoGlueCatalog so that views are rejected early with a clean TableNotFoundException instead of relying on catching exceptions thrown deep inside Iceberg table loading.

In HiveMetadata.streamTableColumns(), pre-check the metastore before entering the try block so views are skipped without triggering (and catching) a TrinoException.

Additional context and related issues

Fixes #29163

The core insight is that getRefreshedLocation() is only reachable through the loadTable()loadIcebergTable()refresh() call chain, so moving the view check into loadTable() makes the downstream check dead code.

Changes

Iceberg – HMS catalog

  • TrinoHiveCatalog.loadTable(): Fetch the metastore table upfront; throw TableNotFoundException if absent or any kind of view.
  • AbstractMetastoreTableOperations.getRefreshedLocation(): Remove now-dead view detection block and unused imports.

Iceberg – Glue catalog

  • TrinoGlueCatalog.loadTable(): Check isTrinoView/isTrinoMaterializedView before creating TableOperations; throw TableNotFoundException early.
  • GlueIcebergTableOperations.getRefreshedLocation(): Remove now-dead view detection block and unused imports/variables.

Hive

  • HiveMetadata.streamTableColumns(): Pre-check the metastore table before the try block; return Stream.empty() when the table is missing or is a view (unless it is a Hive view and translateHiveViews is enabled).

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.

@cla-bot cla-bot Bot added the cla-signed label Apr 24, 2026
@github-actions github-actions Bot added iceberg Iceberg connector hive Hive connector labels Apr 24, 2026
@laserninja laserninja requested review from ebyhr and findepi April 24, 2026 23:53
…layers

Move view/materialized-view detection from getRefreshedLocation() to
loadTable() in both TrinoHiveCatalog and TrinoGlueCatalog so that views
are rejected early with a clean TableNotFoundException instead of
relying on catching exceptions thrown deep inside Iceberg table loading.

In HiveMetadata.streamTableColumns(), pre-check the metastore before
entering the try block so views are skipped without triggering (and
catching) a TrinoException.

Closes trinodb#29163
@laserninja laserninja force-pushed the fix/29163-replace-exception-driven-view-detection branch from e587bdd to 20787f6 Compare April 25, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed hive Hive connector iceberg Iceberg connector

Development

Successfully merging this pull request may close these issues.

Replace exception-driven view detection in Hive and Iceberg metadata layers

1 participant