{"record":{"id":"ba1227098ea9b53e","repo":"apache/iceberg","slug":"cannot-update-the-location-of-a-s-table","errorCode":null,"errorMessage":"Cannot update the location of a %s table","messagePattern":"Cannot update the location of a (.+?) table","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java","lineNumber":55,"sourceCode":"    throw new UnsupportedOperationException(\n        \"Cannot update the partition spec of a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public UpdateProperties updateProperties() {\n    throw new UnsupportedOperationException(\n        \"Cannot update the properties of a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public ReplaceSortOrder replaceSortOrder() {\n    throw new UnsupportedOperationException(\n        \"Cannot update the sort order of a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public UpdateLocation updateLocation() {\n    throw new UnsupportedOperationException(\n        \"Cannot update the location of a \" + descriptor + \" table\");\n  }\n\n  @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  }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java#L37-L73","documentation":"Iceberg throws this UnsupportedOperationException when updateLocation() is called on a read-only table. Changing a table's storage location is a metadata write that BaseReadOnlyTable subclasses reject by design. The descriptor in the message names the read-only table kind.","triggerScenarios":"Calling table.updateLocation().setTableLocation(...) on a metadata table or any BaseReadOnlyTable subclass instance.","commonSituations":"Migration/relocation scripts that rewrite table locations against whatever Table object is in scope, hitting a metadata table handle instead of the data table.","solutions":["Load the writable data table via catalog.loadTable(identifier) and call updateLocation() there.","For relocation, some catalogs require creating the table at the new location or using catalog-level operations instead of updateLocation().","Read the current location with table.location() instead of attempting to set it on a read-only view."],"exampleFix":"// before\ntable.history().updateLocation().setTableLocation(\"s3://bucket/new-path\").commit();\n\n// after\nTable dataTable = catalog.loadTable(TableIdentifier.of(\"db\", \"tbl\"));\ndataTable.updateLocation().setTableLocation(\"s3://bucket/new-path\").commit();","handlingStrategy":"try-catch","validationCode":"if (isMetadataTableName(table.name())) { throw new IllegalArgumentException(\"Cannot relocate metadata table \" + table.name()); }","typeGuard":"boolean canSetLocation = !(table instanceof BaseReadOnlyTable); // ensure handle came from Catalog.loadTable","tryCatchPattern":"try {\n  table.updateLocation().setTableLocation(newUri).commit();\n} catch (UnsupportedOperationException e) {\n  log.error(\"Location is not updatable on read-only table {}\", table.name(), e);\n}","preventionTips":["Relocate only catalog-loaded data tables.","Be aware some catalogs forbid location changes entirely; check catalog docs first.","Read location via table.location() instead of attempting updates on read-only views."],"tags":["unsupported-operation","table-location","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-14T16:17:12.679Z"}