apache/iceberg · error · RuntimeException

content type of from identifier

Error message

content type of from identifier %s should be of %s

What it means

Thrown by validateFromContentForRename when the content found under the from identifier exists but is of a different type than requested (e.g. an IcebergTable found while a view rename was requested). The rename is aborted before any Nessie commit. Message includes the identifier and the expected type.

Solutions

  1. Check the actual content type: use catalog.tableExists vs catalog.viewExists before renaming.
  2. Call the matching rename API (renameTable for tables, renameView for views).
  3. If the content type changed intentionally, drop/recreate or rename with the correct API.

Example fix

// before
catalog.renameView(TableIdentifier.of("ns", "summary"), TableIdentifier.of("ns", "summary_v2")); // summary is a table
// after
TableIdentifier from = TableIdentifier.of("ns", "summary");
if (catalog.tableExists(from)) {
  catalog.renameTable(from, TableIdentifier.of("ns", "summary_v2"));
} else if (catalog.viewExists(from)) {
  catalog.renameView(from, TableIdentifier.of("ns", "summary_v2"));
}
Defensive patterns

Strategy: validation

Validate before calling

boolean isTable = catalog.tableExists(from); boolean isView = catalog.viewExists(from); if (!isTable && !isView) throw ...; 

Try / catch

try { catalog.renameView(from, to); } catch (RuntimeException e) { if (e.getMessage().contains("should be of")) { /* wrong content type; pick matching API */ } }

Prevention

When it happens

Trigger: Calling renameView(from, to) where from is actually a table, or renameTable where from is a view; also when the same path has different content on a different ref than assumed.

Common situations: A table was replaced by a view (or vice versa) under the same name; developer assumed view but the name refers to a table; branch checked out shows different content type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:541

        throw new AlreadyExistsException(
            "Cannot rename %s to %s. Another content of type %s with same name already exists",
            from, to, existingToContent.getType());
      }
    }
  }

  private static void validateFromContentForRename(
      TableIdentifier from, Content.Type type, IcebergContent existingFromContent) {
    if (existingFromContent == null) {
      if (type == Content.Type.ICEBERG_VIEW) {
        throw new NoSuchViewException("View does not exist: %s", from);
      } else if (type == Content.Type.ICEBERG_TABLE) {
        throw new NoSuchTableException("Table does not exist: %s", from);
      } else {
        throw new RuntimeException("Cannot perform rename for content type: " + type);
      }
    } else if (existingFromContent.getType() != type) {
      throw new RuntimeException(
          String.format("content type of from identifier %s should be of %s", from, type));
    }
  }

  public boolean dropTable(TableIdentifier identifier, boolean purge) {
    return dropContent(identifier, purge, Content.Type.ICEBERG_TABLE);
  }

  public boolean dropView(TableIdentifier identifier, boolean purge) {
    return dropContent(identifier, purge, Content.Type.ICEBERG_VIEW);
  }

  private boolean dropContent(TableIdentifier identifier, boolean purge, Content.Type type) {
    getRef().checkMutable();

    IcebergContent existingContent = fetchContent(identifier);
    if (existingContent == null) {
      return false;

View on GitHub (pinned to 86d9c8fc54)