apache/iceberg · error · RuntimeException

Cannot drop : not matching with the type

Error message

Cannot drop %s: not matching with the type `%s`

What it means

Thrown from NessieIcebergClient.dropContent when the content under the identifier exists but its Nessie type does not match the type being dropped (table vs view). The drop is aborted to prevent deleting the wrong kind of object. The message shows the identifier and the requested type string.

Solutions

  1. Check type first with catalog.tableExists / catalog.viewExists and call the matching drop method.
  2. If the intent is to remove the object regardless of kind, branch on the exists checks and call dropTable or dropView accordingly.
  3. Correct the identifier if it points at the wrong object.

Example fix

// before
catalog.dropTable(TableIdentifier.of("ns", "daily"), false); // daily is a view
// after
TableIdentifier id = TableIdentifier.of("ns", "daily");
if (catalog.viewExists(id)) {
  catalog.dropView(id);
} else if (catalog.tableExists(id)) {
  catalog.dropTable(id, false);
}
Defensive patterns

Strategy: validation

Validate before calling

if (catalog.viewExists(id)) { catalog.dropView(id); } else if (catalog.tableExists(id)) { catalog.dropTable(id, purge); }

Try / catch

try { catalog.dropTable(id, false); } catch (RuntimeException e) { if (e.getMessage().startsWith("Cannot drop")) { /* wrong type; use dropView */ } else { throw e; } }

Prevention

When it happens

Trigger: catalog.dropTable(id) where id is actually a view, or dropView(id) where id is a table; also identifiers that resolve to non-Iceberg Nessie content.

Common situations: SQL scripts blindly running DROP TABLE on names that were converted to views; automation using the wrong catalog method; confusion after renaming content between table/view kinds.

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/d1713c504a6748e2. Report an issue: GitHub.

Appendix: source

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

  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;
    }

    if (existingContent.getType() != type) {
      throw new RuntimeException(
          String.format(
              "Cannot drop %s: not matching with the type `%s`",
              identifier, NessieUtil.contentTypeString(type)));
    }

    String contentType = NessieUtil.contentTypeString(type).toLowerCase(Locale.ROOT);

    if (purge) {
      LOG.info(
          "Purging data for {} {} was set to true but is ignored",
          contentType,
          identifier.toString());
    }

    // We try to drop the content. Simple retry after ref update.
    try {
      commitRetry(
          String.format("Iceberg delete %s %s", contentType, identifier),

View on GitHub (pinned to 86d9c8fc54)