{"record":{"id":"5d260bd3e81cb464","repo":"apache/iceberg","slug":"cannot-overwrite-in-a-s-table","errorCode":null,"errorMessage":"Cannot overwrite in a %s table","messagePattern":"Cannot overwrite in a (.+?) table","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java","lineNumber":77,"sourceCode":"  @Override\n  public AppendFiles newAppend() {\n    throw new UnsupportedOperationException(\"Cannot append to a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public RewriteFiles newRewrite() {\n    throw new UnsupportedOperationException(\"Cannot rewrite in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public RewriteManifests rewriteManifests() {\n    throw new UnsupportedOperationException(\n        \"Cannot rewrite manifests in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public OverwriteFiles newOverwrite() {\n    throw new UnsupportedOperationException(\"Cannot overwrite in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public RowDelta newRowDelta() {\n    throw new UnsupportedOperationException(\n        \"Cannot remove or replace rows in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public ReplacePartitions newReplacePartitions() {\n    throw new UnsupportedOperationException(\n        \"Cannot replace partitions in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public DeleteFiles newDelete() {\n    throw new UnsupportedOperationException(\"Cannot delete from a \" + descriptor + \" table\");\n  }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java#L59-L95","documentation":"Iceberg throws this UnsupportedOperationException when newOverwrite() is called on a read-only table. Overwriting files replaces data and commits a snapshot, a write that BaseReadOnlyTable subclasses never allow. The descriptor identifies the read-only table kind.","triggerScenarios":"Calling table.newOverwrite().overwriteByRowFilter(...).commit() (or addFile/deleteFile variants) on a metadata table or any BaseReadOnlyTable subclass instance.","commonSituations":"Data-fix/backfill jobs that resolve Table objects loosely and end up with a metadata-table handle, then attempt overwrite corrections.","solutions":["Perform overwrites on the writable data table from catalog.loadTable(identifier).","Assert the Table is not a read-only/metadata table before starting overwrite work.","Use table.newDelete() on the data table if the intent was only removing files."],"exampleFix":"// before\ntable.files().newOverwrite().overwriteByRowFilter(expr).commit();\n\n// after\nTable dataTable = catalog.loadTable(TableIdentifier.of(\"db\", \"tbl\"));\ndataTable.newOverwrite().overwriteByRowFilter(expr).commit();","handlingStrategy":"try-catch","validationCode":"if (isMetadataTableName(table.name())) { throw new IllegalArgumentException(\"Cannot overwrite files of metadata table \" + table.name()); }","typeGuard":"boolean canOverwrite = !(table instanceof BaseReadOnlyTable); // ensure handle came from Catalog.loadTable","tryCatchPattern":"try {\n  table.newOverwrite().overwriteByRowFilter(expr).commit();\n} catch (UnsupportedOperationException e) {\n  log.error(\"Overwrite is not supported on read-only table {}\", table.name(), e);\n}","preventionTips":["Pass catalog-loaded data tables into data-fix/backfill jobs.","Resolve Table handles by identifier at write time, not by reference reuse.","Verify format support and writability before starting overwrite plans."],"tags":["unsupported-operation","overwrite","read-only-table"],"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"}