{"record":{"id":"2c7d782692ce4694","repo":"apache/iceberg","slug":"does-not-support-creating-tables-2c7d78","errorCode":null,"errorMessage":" does not support creating tables","messagePattern":" does not support creating tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":77,"sourceCode":"  @Override\n  public SparkTable loadTable(Identifier ident, String version) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\n  }\n\n  @Override\n  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(Identifier ident, TableInfo tableInfo)\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","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L59-L95","documentation":"SparkRewriteTableCatalog.createTable(ident, tableInfo) always throws UnsupportedOperationException because this catalog only serves already-existing tables registered by rewrite procedures; table creation must go through a real Iceberg catalog.","triggerScenarios":"Calling createTable on SparkRewriteTableCatalog, or a generic catalog client attempting DDL (CREATE TABLE) against the rewrite catalog identifier.","commonSituations":"Configuring the rewrite catalog as a default/session catalog so CREATE TABLE routes to it; automated DDL migrations that iterate all catalogs.","solutions":["Create tables via the real catalog: SparkCatalog, HadoopCatalog, HiveCatalog, or REST catalog.","Use SQL CREATE TABLE against the source catalog, never the rewrite catalog.","Do not register SparkRewriteTableCatalog as a default catalog for DDL workloads."],"exampleFix":"// before\nrewriteCatalog.createTable(ident, tableInfo);\n// after\nsparkCatalog.createTable(ident, schema, spec, properties); // DDL via the real catalog","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkRewriteTableCatalog) {\n  throw new IllegalArgumentException(\"CREATE TABLE must target a real Iceberg catalog\");\n}","typeGuard":"boolean supportsCreate(CatalogPlugin c) {\n  return !(c instanceof SparkRewriteTableCatalog);\n}","tryCatchPattern":"try {\n  catalog.createTable(ident, tableInfo);\n} catch (UnsupportedOperationException e) {\n  realCatalog.createTable(ident, schema, spec, properties);\n}","preventionTips":["Register SparkRewriteTableCatalog only for rewrite procedures.","Route DDL to the source catalog.","Audit catalog configuration for default-catalog mistakes.","Capability-check before DDL."],"tags":["spark","rewrite","unsupported-operation","ddl"],"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-14T16:17:12.679Z"}