{"record":{"id":"10e13fecf0467e3d","repo":"apache/iceberg","slug":"replacing-a-view-s-version-is-not-supported","errorCode":null,"errorMessage":"Replacing a view's version is not supported","messagePattern":"Replacing a view's version is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/view/View.java","lineNumber":104,"sourceCode":"   */\n  default String location() {\n    throw new UnsupportedOperationException(\"Retrieving a view's location is not supported\");\n  }\n\n  /**\n   * Create a new {@link UpdateViewProperties} to update view properties.\n   *\n   * @return a new {@link UpdateViewProperties}\n   */\n  UpdateViewProperties updateProperties();\n\n  /**\n   * Create a new {@link ReplaceViewVersion} to replace the view's current version.\n   *\n   * @return a new {@link ReplaceViewVersion}\n   */\n  default ReplaceViewVersion replaceVersion() {\n    throw new UnsupportedOperationException(\"Replacing a view's version is not supported\");\n  }\n\n  /**\n   * Create a new {@link UpdateLocation} to set the view's location.\n   *\n   * @return a new {@link UpdateLocation}\n   */\n  default UpdateLocation updateLocation() {\n    throw new UnsupportedOperationException(\"Updating a view's location is not supported\");\n  }\n\n  /**\n   * Returns the view's UUID\n   *\n   * @return the view's UUID\n   */\n  default UUID uuid() {\n    throw new UnsupportedOperationException(\"Retrieving a view's uuid is not supported\");","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/view/View.java#L86-L122","documentation":"View.replaceVersion() is a default interface method that throws UnsupportedOperationException. Creating a ReplaceViewVersion builder is only supported by View implementations that can produce full view metadata updates (e.g. BaseView). Catalog adapters that do not support view version replacement surface this error.","triggerScenarios":"Calling view.replaceVersion() to build a ReplaceViewVersion operation on a View implementation that has not overridden it.","commonSituations":"Replacing a view's current SQL version via the catalog API on a catalog whose loaded View lacks replaceVersion support; custom View wrappers in tests.","solutions":["Load the view from a catalog whose implementation supports replaceVersion() (override it in custom implementations, typically by extending BaseView).","Use engine-level SQL (CREATE OR REPLACE VIEW) instead of the Java ReplaceViewVersion API.","Check the catalog's view-support capabilities before calling replaceVersion()."],"exampleFix":"// before\nview.replaceVersion()\n    .replaceCurrentVersion(sql, \"spark\", comments, elements)\n    .commit();\n\n// after\nif (viewSupportsReplaceVersion(view)) {\n  view.replaceVersion()\n      .replaceCurrentVersion(sql, \"spark\", comments, elements)\n      .commit();\n} else {\n  catalog.buildReplaceViewVersion(...).createOrReplace().commit();\n}","handlingStrategy":"type-guard","validationCode":"boolean canReplace = view instanceof BaseView;","typeGuard":"static boolean supportsReplaceVersion(View v) { return v instanceof BaseView; }","tryCatchPattern":"try { view.replaceVersion()...commit(); } catch (UnsupportedOperationException e) { /* use SQL CREATE OR REPLACE VIEW fallback */ }","preventionTips":["Verify catalog view-replacement support before using ReplaceViewVersion","Prefer engine SQL (CREATE OR REPLACE VIEW) for broad compatibility"],"tags":["java","iceberg","view","unsupported-operation"],"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"}