apache/iceberg · error · NoSuchViewException

View does not exist: %s.%s

Error message

View does not exist: %s.%s

What it means

HiveViewOperations.doRefresh wraps the HMS getView call; if Hive reports NoSuchObjectException but this operation already has a current metadata location, the view previously existed and was dropped, so it throws NoSuchViewException with the database and view name. If there was no prior location, refresh simply treats it as a non-existent view (used during create).

Source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java:104

  @Override
  public void doRefresh() {
    String metadataLocation = null;
    Table table;

    try {
      table = metaClients.run(client -> client.getTable(database, viewName));

      // Check if we are trying to load an Iceberg Table as a View
      HiveOperationsBase.validateIcebergTableNotLoadedAsIcebergView(table, fullName);
      // Check if it is a valid Iceberg View
      HiveOperationsBase.validateTableIsIcebergView(table, fullName);

      metadataLocation =
          table.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);

    } catch (NoSuchObjectException e) {
      if (currentMetadataLocation() != null) {
        throw new NoSuchViewException("View does not exist: %s.%s", database, viewName);
      }
    } catch (TException e) {
      String errMsg =
          String.format("Failed to get view info from metastore %s.%s", database, viewName);
      throw new RuntimeException(errMsg, e);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException("Interrupted during refresh", e);
    }

    refreshFromMetadataLocation(metadataLocation);
  }

  @SuppressWarnings("checkstyle:CyclomaticComplexity")
  @Override
  public void doCommit(ViewMetadata base, ViewMetadata metadata) {
    boolean newView = base == null;
    String newMetadataLocation = writeNewMetadataIfRequired(metadata);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Re-create the view or re-load it from the catalog to obtain a fresh handle.
  2. Check the view's existence with the catalog/HMS before refreshing in long-lived jobs.
  3. Coordinate DDL so views are not dropped while readers hold references; use retries that re-resolve the identifier on NoSuchViewException.
  4. Verify you are connected to the correct metastore/database (view may exist elsewhere).

Example fix

// before
View view = catalog.loadView(identifier);
view.refresh(); // NoSuchViewException if dropped
// after
if (catalog.viewExists(identifier)) {
  catalog.loadView(identifier).refresh();
} else {
  // recreate or re-resolve
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!catalog.viewExists(identifier)) {
  throw new IllegalStateException(identifier + " does not exist; refresh skipped");
}

Try / catch

try {
  view.refresh();
} catch (NoSuchViewException e) {
  // view was dropped concurrently; reload or recreate
  view = catalog.loadView(identifier); // or handle absence
}

Prevention

When it happens

Trigger: Calling refreshView or any refresh-triggering view operation when the view was deleted from Hive between load and refresh (currentMetadataLocation() != null but HMS getView throws NoSuchObjectException).

Common situations: Another job or user dropped the view concurrently; pointing at a database where the view was dropped; staging/refresh environments where views are recreated; stale catalog handles after DDL.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/f8b8d3ecfe4dea22. Report an issue: GitHub.