{"record":{"id":"d1713c504a6748e2","repo":"apache/iceberg","slug":"cannot-drop-s-not-matching-with-the-type-s","errorCode":null,"errorMessage":"Cannot drop %s: not matching with the type `%s`","messagePattern":"Cannot drop (.+?): not matching with the type `(.+?)`","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":563,"sourceCode":"\n  public boolean dropTable(TableIdentifier identifier, boolean purge) {\n    return dropContent(identifier, purge, Content.Type.ICEBERG_TABLE);\n  }\n\n  public boolean dropView(TableIdentifier identifier, boolean purge) {\n    return dropContent(identifier, purge, Content.Type.ICEBERG_VIEW);\n  }\n\n  private boolean dropContent(TableIdentifier identifier, boolean purge, Content.Type type) {\n    getRef().checkMutable();\n\n    IcebergContent existingContent = fetchContent(identifier);\n    if (existingContent == null) {\n      return false;\n    }\n\n    if (existingContent.getType() != type) {\n      throw new RuntimeException(\n          String.format(\n              \"Cannot drop %s: not matching with the type `%s`\",\n              identifier, NessieUtil.contentTypeString(type)));\n    }\n\n    String contentType = NessieUtil.contentTypeString(type).toLowerCase(Locale.ROOT);\n\n    if (purge) {\n      LOG.info(\n          \"Purging data for {} {} was set to true but is ignored\",\n          contentType,\n          identifier.toString());\n    }\n\n    // We try to drop the content. Simple retry after ref update.\n    try {\n      commitRetry(\n          String.format(\"Iceberg delete %s %s\", contentType, identifier),","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L545-L581","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncatalog.dropTable(TableIdentifier.of(\"ns\", \"daily\"), false); // daily is a view\n// after\nTableIdentifier id = TableIdentifier.of(\"ns\", \"daily\");\nif (catalog.viewExists(id)) {\n  catalog.dropView(id);\n} else if (catalog.tableExists(id)) {\n  catalog.dropTable(id, false);\n}","handlingStrategy":"validation","validationCode":"if (catalog.viewExists(id)) { catalog.dropView(id); } else if (catalog.tableExists(id)) { catalog.dropTable(id, purge); }","typeGuard":null,"tryCatchPattern":"try { catalog.dropTable(id, false); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Cannot drop\")) { /* wrong type; use dropView */ } else { throw e; } }","preventionTips":["Never call dropTable/dropView blindly from scripts","Check exists APIs first on the same catalog instance/ref","Avoid table/view name collisions in namespaces"],"tags":["nessie","drop","type-mismatch","catalog"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}