{"record":{"id":"46a5124adbb23ee3","repo":"apache/iceberg","slug":"class-name-does-not-support-altering-tables","errorCode":null,"errorMessage":"${CLASS_NAME} does not support altering tables","messagePattern":"(.+?) does not support altering tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":85,"sourceCode":"  public SparkTable loadTable(Identifier ident, long timestampMicros) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\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":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L67-L103","documentation":"SparkRewriteTableCatalog.alterTable always throws UnsupportedOperationException because schema/property changes are not applicable to its procedure-scoped table cache. ALTER TABLE statements routed through this catalog fail immediately.","triggerScenarios":"Calling alterTable(ident, changes) on a SparkRewriteTableCatalog, e.g. ALTER TABLE ... ADD COLUMN executed while that catalog binding is active.","commonSituations":"ALTER TABLE routed to the wrong catalog binding; programmatic schema evolution attempts during a rewrite session.","solutions":["Issue ALTER TABLE through SparkCatalog or another real Iceberg catalog","Verify the catalog binding for the namespace in your session (DESCRIBE / SHOW CATALOGS)","Separate DDL from rewrite procedures in your job","Fix catalog config so user-facing namespaces use SparkCatalog"],"exampleFix":"// before\nspark.sql(\"ALTER TABLE prod.db.events ADD COLUMN c INT\") // via rewrite catalog\n// after\nspark.sql(\"CALL prod.system.rewrite_data_files(table => 'db.events')\") // rewrites only\nspark.sql(\"ALTER TABLE prod.db.events ADD COLUMN c INT\") // via SparkCatalog","handlingStrategy":"validation","validationCode":"val impl = spark.conf.get(\"spark.sql.catalog.prod.catalog-impl\", \"\")\nrequire(impl != \"org.apache.iceberg.spark.SparkRewriteTableCatalog\", \"ALTER TABLE not supported on rewrite catalog\")","typeGuard":null,"tryCatchPattern":"try {\n  catalog.alterTable(ident, changes: _*)\n} catch {\n  case _: UnsupportedOperationException => alterViaRealCatalog(ident, changes: _*)\n}","preventionTips":["Route ALTER TABLE to SparkCatalog bindings","Keep DDL out of rewrite-procedure sessions","Verify per-namespace catalog bindings before schema changes"],"tags":["spark","catalog","alter-table","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-23T08:17:48.524Z"}