{"record":{"id":"782fdeb17861f7dc","repo":"apache/iceberg","slug":"sparkcachedtablecatalog-does-not-support-dropping","errorCode":null,"errorMessage":"SparkCachedTableCatalog does not support dropping tables","messagePattern":"SparkCachedTableCatalog does not support dropping tables","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java","lineNumber":108,"sourceCode":"  public void invalidateTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support table invalidation\");\n  }\n\n  @Override\n  public SparkTable createTable(\n      Identifier ident, StructType schema, Transform[] partitions, Map<String, String> properties)\n      throws TableAlreadyExistsException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support creating tables\");\n  }\n\n  @Override\n  public SparkTable alterTable(Identifier ident, TableChange... changes) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support altering tables\");\n  }\n\n  @Override\n  public boolean dropTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support dropping tables\");\n  }\n\n  @Override\n  public boolean purgeTable(Identifier ident) throws UnsupportedOperationException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support purging tables\");\n  }\n\n  @Override\n  public void renameTable(Identifier oldIdent, Identifier newIdent) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support renaming tables\");\n  }\n\n  @Override\n  public void initialize(String catalogName, CaseInsensitiveStringMap options) {\n    this.name = catalogName;\n  }\n\n  @Override","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L90-L126","documentation":"SparkCachedTableCatalog.dropTable() unconditionally throws UnsupportedOperationException. The cached catalog only reads tables into a cache; it has no authority (or mechanism) to delete the underlying table from its owning catalog, so dropping is rejected by design.","triggerScenarios":"Calling SparkCachedTableCatalog.dropTable(ident), or executing DROP TABLE in Spark SQL when the identifier resolves to the cached-table catalog.","commonSituations":"Cleanup scripts that DROP TABLE a list of names without knowing which catalog resolved them; test harnesses assuming any CatalogPlugin supports drop; user runs DROP TABLE after querying via the cached path and expects the drop to hit the source table.","solutions":["Issue the DROP TABLE against the catalog that owns the table (e.g. the SparkSession catalog the table was cached from).","Use Spark SQL with the fully qualified original identifier (spark_catalog.db.t) rather than the cached namespace.","If programmatic, obtain the org.apache.iceberg.catalog.SupportsDelete catalog and call dropTable there."],"exampleFix":"// before\ncachedCatalog.dropTable(Identifier.of(new String[]{\"db\"}, \"t\"));\n\n// after\nspark.sql(\"DROP TABLE spark_catalog.db.t\"); // resolves to the owning catalog","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) {\n  throw new IllegalArgumentException(\"dropTable is not supported on SparkCachedTableCatalog; use the owning catalog\");\n}","typeGuard":"boolean canDrop = !(catalog instanceof SparkCachedTableCatalog);","tryCatchPattern":"try {\n  catalog.dropTable(ident);\n} catch (UnsupportedOperationException e) {\n  // fall back to owning catalog: spark.sql(\"DROP TABLE spark_catalog.db.t\")\n}","preventionTips":["Never build cleanup/retention jobs on top of the cached catalog.","Resolve the owning catalog from the original identifier before destructive operations.","Add unit checks in tooling that DDL targets SparkCatalog/HiveCatalog, never the cached wrapper."],"tags":["spark","catalog","ddl","unsupported-operation","cached-table"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}