{"record":{"id":"f2ad6beefea08e4b","repo":"apache/iceberg","slug":"registering-tables-with-overwrite-is-not-supported-f2ad6b","errorCode":null,"errorMessage":"Registering tables with overwrite is not supported","messagePattern":"Registering tables with overwrite is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java","lineNumber":196,"sourceCode":"   *\n   * @param context session context\n   * @param ident a table identifier\n   * @param metadataFileLocation the location of a metadata file\n   * @param overwrite whether to overwrite an existing table registration\n   * @return a Table instance\n   * @throws AlreadyExistsException if {@code overwrite} is false and the table already exists in\n   *     the catalog\n   */\n  default Table registerTable(\n      SessionContext context,\n      TableIdentifier ident,\n      String metadataFileLocation,\n      boolean overwrite) {\n    if (!overwrite) {\n      return registerTable(context, ident, metadataFileLocation);\n    }\n\n    throw new UnsupportedOperationException(\"Registering tables with overwrite is not supported\");\n  }\n\n  /**\n   * Check whether table exists.\n   *\n   * @param context session context\n   * @param ident a table identifier\n   * @return true if the table exists, false otherwise\n   */\n  default boolean tableExists(SessionContext context, TableIdentifier ident) {\n    try {\n      loadTable(context, ident);\n      return true;\n    } catch (NoSuchTableException e) {\n      return false;\n    }\n  }\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java#L178-L214","documentation":"SessionCatalog.registerTable(context, ident, metadataFileLocation, overwrite) throws UnsupportedOperationException when overwrite=true unless the session-scoped catalog overrides it. Like the plain Catalog interface, only the non-overwrite case falls back to the two-argument registerTable default. It indicates the SessionCatalog implementation does not support overwrite registration.","triggerScenarios":"Calling registerTable with overwrite=true on a SessionCatalog implementation that has not overridden the four-argument method, typically reached through an ASGC/IsolatedViewEngine or wrapped session catalog path.","commonSituations":"Custom session catalogs (in-memory, test stubs, wrappers around catalogs lacking registration) used in multi-session engines; overwrite-style table re-registration in session-scoped engines; version drift where the wrapper predates the overwrite API.","solutions":["Call the non-overload registerTable(context, ident, metadataFileLocation) after dropping any existing table","Upgrade to a SessionCatalog implementation that supports overwrite registration","Override the four-argument registerTable in the custom SessionCatalog","Restructure the workflow to avoid overwrite semantics (new identifier or drop-then-register)"],"exampleFix":"// before\nsessionCatalog.registerTable(context, ident, metadataFileLocation, true);\n// after\nsessionCatalog.dropTable(context, ident);\nsessionCatalog.registerTable(context, ident, metadataFileLocation);","handlingStrategy":"try-catch","validationCode":"if (overwrite) {\n  // verify the SessionCatalog implementation supports overwrite registration first\n}","typeGuard":null,"tryCatchPattern":"try {\n  sessionCatalog.registerTable(context, ident, metadataFileLocation, true);\n} catch (UnsupportedOperationException e) {\n  sessionCatalog.dropTable(context, ident);\n  sessionCatalog.registerTable(context, ident, metadataFileLocation);\n}","preventionTips":["Prefer the two-argument registerTable in session-scoped code","Keep custom SessionCatalog implementations in sync with the Catalog interface's capabilities","Avoid overwrite flags when wrapping catalogs of unknown capability","Test session catalog registration flows against the real backend catalog"],"tags":["java","unsupported-operation","session-catalog","overwrite"],"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"}