{"record":{"id":"21509786185d5fe2","repo":"apache/iceberg","slug":"retrieving-a-view-s-location-is-not-supported","errorCode":null,"errorMessage":"Retrieving a view's location is not supported","messagePattern":"Retrieving a view's location is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/view/View.java","lineNumber":88,"sourceCode":"   *\n   * @return a list of {@link ViewHistoryEntry}\n   */\n  List<ViewHistoryEntry> history();\n\n  /**\n   * Return a map of string properties for this view.\n   *\n   * @return this view's properties map\n   */\n  Map<String, String> properties();\n\n  /**\n   * Return the view's base location.\n   *\n   * @return this view's location\n   */\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","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/view/View.java#L70-L106","documentation":"View.location() is a default method on the View interface that intentionally throws UnsupportedOperationException. Iceberg uses interface defaults so that concrete catalog implementations (e.g. REST-backed views) only override the methods they support. Hitting this means the concrete View implementation in use does not expose the view's base location.","triggerScenarios":"Calling view.location() on a View object returned by a catalog (e.g. loadView) whose implementation does not override location().","commonSituations":"Code written against a mock or custom View implementation in tests; catalogs that return a minimal View wrapper; code assuming all View implementations behave like BaseView.","solutions":["Use a catalog/View implementation that overrides location() (e.g. one built on BaseView or the standard metadata-backed view).","If you only need the location to create/update the view, use SQL extensions (CREATE VIEW ... LOCATION) or catalog-level APIs instead of reading location() from the returned object.","In tests, replace stub Views with real implementations that override location()."],"exampleFix":"// before\nString loc = view.location();\n\n// after\nif (view instanceof BaseView) {\n  String loc = ((BaseView) view).location();\n} else {\n  // fall back to catalog metadata or skip location-dependent logic\n}","handlingStrategy":"type-guard","validationCode":"boolean supportsLocation = !(view.getClass().getSimpleName().equals(\"View\") && isDefaultMethod(view, \"location\"));","typeGuard":"static boolean supportsLocation(View v) { return v instanceof BaseView; }","tryCatchPattern":"try { return view.location(); } catch (UnsupportedOperationException e) { return null; }","preventionTips":["Load views from catalogs returning BaseView-backed implementations","Avoid stubbing the View interface in tests without overriding used methods"],"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"}