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
- Check type first with catalog.tableExists / catalog.viewExists and call the matching drop method.
- If the intent is to remove the object regardless of kind, branch on the exists checks and call dropTable or dropView accordingly.
- 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
- Never call dropTable/dropView blindly from scripts
- Check exists APIs first on the same catalog instance/ref
- Avoid table/view name collisions in namespaces
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
- Content object with name
- content type of from identifier
- Cannot initialize Catalog
- Cannot load namespace
- Cannot rename ' ' to ' ': ref ' ' no longer exists.
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)