{"record":{"id":"352ed9198ddac46d","repo":"apache/iceberg","slug":"does-not-support-creating-tables","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.0/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java","lineNumber":98,"sourceCode":"    SparkTable table = load(ident);\n    Preconditions.checkArgument(\n        table.snapshotId() == null, \"Cannot time travel based on both table identifier and AS OF\");\n    // Spark passes microseconds but Iceberg uses milliseconds for snapshots\n    long timestampMillis = TimeUnit.MICROSECONDS.toMillis(timestampMicros);\n    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","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L80-L116","documentation":"This UnsupportedOperationException is a deliberate guard in SparkCachedTableCatalog.createTable: the catalog only serves cached views of already-existing Iceberg tables, so it has no write path to register a new table. Any Spark call that resolves CREATE TABLE (or REPLACE/CREATE OR REPLACE) against this catalog — e.g. a CREATE TABLE USING iceberg statement routed here instead of SparkCatalog — hits this sentinel and fails immediately, before any IO occurs.","triggerScenarios":"Running CREATE TABLE ... USING iceberg with the cached catalog as the target catalog, invoking Catalog#createTable via Spark's TableCatalog API.","commonSituations":"Misconfigured default/session catalog pointing at SparkCachedTableCatalog; user attempts DDL in SQL expecting a persistent catalog.","solutions":["Create tables in the real Iceberg catalog (SparkCatalog), not the cached-table catalog","Set spark.sql.defaultCatalog to the persistent Iceberg catalog for DDL","Cache the created table via SparkTableCache first if you need it served by this catalog"],"exampleFix":"// before\nspark.sql(\"CREATE TABLE cached_catalog.db.t ...\")\n// after\nspark.conf.set(\"spark.sql.defaultCatalog\", \"iceberg_real\");\nspark.sql(\"CREATE TABLE iceberg_real.db.t ...\")","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) {\n  throw new IllegalArgumentException(\"Use the persistent Iceberg catalog to create tables\");\n}","typeGuard":null,"tryCatchPattern":"try { catalog.createTable(ident, schema, partitions, props); } catch (UnsupportedOperationException e) { realCatalog.createTable(ident, schema, partitions, props); }","preventionTips":["Set spark.sql.defaultCatalog to a persistent catalog for DDL","Never target the cached catalog in CREATE TABLE statements"],"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"}