{"record":{"id":"e0df8d2292b0bfac","repo":"apache/iceberg","slug":"sparkcachedtablecatalog-does-not-support-creating","errorCode":null,"errorMessage":"SparkCachedTableCatalog does not support creating tables","messagePattern":"SparkCachedTableCatalog does not support creating 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":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/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L80-L116","documentation":"Capability guard in SparkCachedTableCatalog.createTable: this catalog only serves loads of already-existing (cached) tables and cannot create them. Any CREATE attempt routed here fails; route the operation to the underlying Iceberg catalog instead.","triggerScenarios":"Executing CREATE TABLE (or CREATE OR REPLACE TABLE) against the cached-table catalog, or API calls to createTable(ident, schema, partitions, properties) on this catalog.","commonSituations":"Queries that reference the cached catalog name by mistake in DDL; framework code attempting to materialize results into every available catalog.","solutions":["Create tables in the real catalog (spark_catalog / Iceberg catalog) rather than the cached-table catalog","Ensure identifier resolution doesn't route DDL to SparkCachedTableCatalog","If you need a persistent reference to cached data, create a temp view instead of a table"],"exampleFix":"// before\nspark.sql(\"CREATE TABLE spark_catalog_cached.db.tbl (id BIGINT)\"); // throws\n// after\nspark.sql(\"CREATE TABLE my_catalog.db.tbl (id BIGINT) USING iceberg\");","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) throw new IllegalStateException(\"DDL not allowed on cached-table catalog\");","typeGuard":null,"tryCatchPattern":"try { catalog.createTable(ident, schema, partitions, props); } catch (UnsupportedOperationException e) { realCatalog.createTable(ident, schema, partitions, props); }","preventionTips":["Route all DDL to real catalogs, never the cached-table catalog","Use temp views for referencing cached data","Validate target catalog before emitting CREATE TABLE statements"],"tags":["spark","catalog","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"}