{"record":{"id":"b91857afd45d7351","repo":"apache/iceberg","slug":"does-not-support-altering-tables","errorCode":null,"errorMessage":" does not support altering tables","messagePattern":" does not support altering tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java","lineNumber":103,"sourceCode":"    long snapshotId = SnapshotUtil.snapshotIdAsOfTime(table.table(), timestampMillis);\n    return table.copyWithSnapshotId(snapshotId);\n  }\n\n  @Override\n  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","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L85-L121","documentation":"Capability guard in SparkCachedTableCatalog.alterTable (v4.0): the cached-table catalog is read-only over its loads, so ALTER TABLE routed here always fails; the alteration must target the underlying catalog.","triggerScenarios":"Running ALTER TABLE statements (add column, set properties, etc.) on a table identifier resolved through the cached-table catalog.","commonSituations":"Users assuming the cached catalog is a full catalog; session catalog misconfiguration so ALTERs are routed to it.","solutions":["Execute ALTER TABLE against the real Iceberg catalog that owns the table","Fully qualify the table with the real catalog name in SQL","After altering in the real catalog, refresh/re-cache the table in SparkTableCache if needed"],"exampleFix":"// before\nALTER TABLE cached_catalog.db.t ADD COLUMN c INT\n// after\nALTER TABLE iceberg_catalog.db.t ADD COLUMN c INT","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) {\n  throw new IllegalArgumentException(\"ALTER TABLE not supported on cached catalog; use owning catalog\");\n}","typeGuard":null,"tryCatchPattern":"try { catalog.alterTable(ident, changes); } catch (UnsupportedOperationException e) { realCatalog.alterTable(ident, changes); }","preventionTips":["Fully qualify ALTER TABLE with the real catalog name","Audit SQL scripts for catalog prefixes routing to the cached catalog"],"tags":["spark","catalog","ddl","unsupported-operation"],"backgroundTag":"operation-not-supported","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}