{"record":{"id":"20f0f33ad621c22f","repo":"apache/iceberg","slug":"operation-newreplacepartitions-is-not-supported-af","errorCode":null,"errorMessage":"Operation newReplacePartitions is not supported after the table is serialized","messagePattern":"Operation newReplacePartitions 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":402,"sourceCode":"\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\n  public ReplacePartitions newReplacePartitions() {\n    throw new UnsupportedOperationException(errorMsg(\"newReplacePartitions\"));\n  }\n\n  @Override\n  public DeleteFiles newDelete() {\n    throw new UnsupportedOperationException(errorMsg(\"newDelete\"));\n  }\n\n  @Override\n  public UpdateStatistics updateStatistics() {\n    throw new UnsupportedOperationException(errorMsg(\"updateStatistics\"));\n  }\n\n  @Override\n  public UpdatePartitionStatistics updatePartitionStatistics() {\n    throw new UnsupportedOperationException(errorMsg(\"updatePartitionStatistics\"));\n  }\n\n  @Override","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/SerializableTable.java#L384-L420","documentation":"A SerializableTable is a read-only, serialized snapshot of a table used in distributed tasks; because it has no catalog connection, ReplacePartitions commits cannot be performed and newReplacePartitions() throws UnsupportedOperationException with this message. Partition replacement mutates table metadata and must go through a live Table.","triggerScenarios":"Calling table.newReplacePartitions() on a SerializableTable deserialized in a worker task, e.g. building a dynamic-partition-overwrite writer in executor code.","commonSituations":"Spark/Flink jobs that serialize the Table and attempt partition-overwrite writes in executors; custom sinks constructed from SerializableTable; helper code shared between driver and executor contexts.","solutions":["Use catalog.loadTable(identifier).newReplacePartitions() on the catalog-connected node","Write via the engine's native overwrite-dynamic-partitions sink rather than manual ReplacePartitions in executors","Restructure so workers only produce files and the driver performs the commit","Add an instanceof SerializableTable guard before write-operations to fail early with a clear message"],"exampleFix":"// before\nTable table = serializedTable;\ntable.newReplacePartitions().appendFile(dataFile).commit();\n// after\nTable table = catalog.loadTable(identifier);\ntable.newReplacePartitions().appendFile(dataFile).commit();","handlingStrategy":"try-catch","validationCode":"if (table instanceof org.apache.iceberg.SerializableTable) {\n  throw new IllegalStateException(\"newReplacePartitions() requires a catalog-backed Table\");\n}","typeGuard":"boolean canReplace = !(table instanceof org.apache.iceberg.SerializableTable);","tryCatchPattern":"try {\n  table.newReplacePartitions().appendFile(f).commit();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"not supported after the table is serialized\")) {\n    catalog.loadTable(identifier).newReplacePartitions().appendFile(f).commit();\n  } else { throw e; }\n}","preventionTips":["Write via engine sinks with dynamic partition overwrite instead of manual commits in executors","Restrict ReplacePartitions to catalog-backed Tables","Ship data files, not Table references, to worker tasks","Guard shared write helpers with instanceof SerializableTable checks"],"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-23T08:17:48.524Z"}