{"record":{"id":"9e83062e274ff975","repo":"apache/iceberg","slug":"operation-newrewrite-is-not-supported-after-the-ta","errorCode":null,"errorMessage":"Operation newRewrite is not supported after the table is serialized","messagePattern":"Operation newRewrite is not supported after the table is serialized","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/SerializableTable.java","lineNumber":382,"sourceCode":"\n  @Override\n  public ReplaceSortOrder replaceSortOrder() {\n    throw new UnsupportedOperationException(errorMsg(\"replaceSortOrder\"));\n  }\n\n  @Override\n  public UpdateLocation updateLocation() {\n    throw new UnsupportedOperationException(errorMsg(\"updateLocation\"));\n  }\n\n  @Override\n  public AppendFiles newAppend() {\n    throw new UnsupportedOperationException(errorMsg(\"newAppend\"));\n  }\n\n  @Override\n  public RewriteFiles newRewrite() {\n    throw new UnsupportedOperationException(errorMsg(\"newRewrite\"));\n  }\n\n  @Override\n  public RewriteManifests rewriteManifests() {\n    throw new UnsupportedOperationException(errorMsg(\"rewriteManifests\"));\n  }\n\n  @Override\n  public OverwriteFiles newOverwrite() {\n    throw new UnsupportedOperationException(errorMsg(\"newOverwrite\"));\n  }\n\n  @Override\n  public RowDelta newRowDelta() {\n    throw new UnsupportedOperationException(errorMsg(\"newRowDelta\"));\n  }\n\n  @Override","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/SerializableTable.java#L364-L400","documentation":"A SerializableTable is a serialized, read-only view of an Iceberg table used on distributed workers. Since rewriting files changes table metadata and requires committing through a catalog, newRewrite() throws UnsupportedOperationException with this message. Use a catalog-backed Table instance for compaction/rewrite operations.","triggerScenarios":"Calling table.newRewrite() on a table obtained by serializing with SerializableTable.wrap(...) and deserializing on a worker node, e.g. inside a distributed maintenance job.","commonSituations":"Custom compaction/rewrite jobs that serialize the Table object and try to perform RewriteFiles inside executors; copying driver code into worker code without realizing the table type changed.","solutions":["Perform the rewrite on a catalog-connected Table: catalog.loadTable(identifier).newRewrite()...commit()","Move RewriteFiles operations to the driver/master node where the table was originally loaded","Use engine-native maintenance tools (e.g. Iceberg Spark procedures like rewrite_data_files) instead of manual rewrites in executors","Reject SerializableTable instances early with an instanceof check before starting rewrite logic"],"exampleFix":"// before\nTable table = serializedCopy;\ntable.newRewrite().rewriteFiles(added, deleted).commit();\n// after\nTable table = catalog.loadTable(identifier); // driver-side, catalog-backed\ntable.newRewrite().rewriteFiles(added, deleted).commit();","handlingStrategy":"try-catch","validationCode":"if (table instanceof org.apache.iceberg.SerializableTable) {\n  throw new IllegalStateException(\"newRewrite() requires a catalog-backed Table\");\n}","typeGuard":"boolean rewritable = !(table instanceof org.apache.iceberg.SerializableTable);","tryCatchPattern":"try {\n  table.newRewrite().rewriteFiles(added, deleted).commit();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"not supported after the table is serialized\")) {\n    catalog.loadTable(identifier).newRewrite().rewriteFiles(added, deleted).commit();\n  } else { throw e; }\n}","preventionTips":["Run rewrites/compaction where the table was loaded from the catalog","Do not serialize Table objects for write jobs; pass identifiers instead","Use maintenance procedures (rewrite_data_files) rather than custom executor rewrites","Fail fast on SerializableTable instances before beginning rewrite plans"],"tags":["java","iceberg","unsupported-operation","serialization"],"backgroundTag":"unsupported-operation","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"}