{"record":{"id":"67d4790a6574ef67","repo":"apache/iceberg","slug":"registering-views-is-not-supported","errorCode":null,"errorMessage":"Registering views is not supported","messagePattern":"Registering views is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/catalog/ViewCatalog.java","lineNumber":133,"sourceCode":"   *\n   * <p>If the view is already loaded or cached, drop cached data. If the view does not exist or is\n   * not cached, do nothing.\n   *\n   * @param identifier a view identifier\n   */\n  default void invalidateView(TableIdentifier identifier) {}\n\n  /**\n   * Register a view with the catalog if it does not exist.\n   *\n   * @param identifier a view identifier\n   * @param metadataFileLocation the location of a metadata file\n   * @return a View instance\n   * @throws AlreadyExistsException if a table/view with the same identifier already exists in the\n   *     catalog.\n   */\n  default View registerView(TableIdentifier identifier, String metadataFileLocation) {\n    throw new UnsupportedOperationException(\"Registering views is not supported\");\n  }\n\n  /**\n   * Initialize a view catalog given a custom name and a map of catalog properties.\n   *\n   * <p>A custom view catalog implementation must have a no-arg constructor. A compute engine like\n   * Spark or Flink will first initialize the catalog without any arguments, and then call this\n   * method to complete catalog initialization with properties passed into the engine.\n   *\n   * @param name a custom name for the catalog\n   * @param properties catalog properties\n   */\n  default void initialize(String name, Map<String, String> properties) {}\n}\n","sourceCodeStart":115,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/catalog/ViewCatalog.java#L115-L148","documentation":"ViewCatalog is an interface that adds view management to a catalog; registerView is a default method that deliberately throws UnsupportedOperationException because not every catalog implementation supports registering (importing) an existing view from a metadata file location. Implementations like HiveCatalog or JdbcCatalog may not override it, so calling it on such a catalog fails at runtime.","triggerScenarios":"Calling catalog.registerView(identifier, metadataFileLocation) on a ViewCatalog implementation that does not override registerView (e.g., a catalog that supports views via create/replace but not metadata-file registration).","commonSituations":"Migrating views between catalogs by pointing at an existing metadata JSON file; tooling that assumes all view catalogs support view registration like table registration; using a custom or older catalog implementation that predates registerView support.","solutions":["Use a catalog implementation that overrides registerView (e.g., RESTCatalog with view support, NessieCatalog) instead of the default-throwing implementation.","If the catalog supports creating views, recreate the view with createView/replaceView using its SQL or view definition instead of registering its metadata file.","Before calling, feature-detect: try registerView and fall back to creation, or check the implementation class/documentation for view registration support.","Add an override of registerView to your custom catalog implementation.","Wrap the call in try-catch for UnsupportedOperationException and surface a clear 'view registration not supported by this catalog' message."],"exampleFix":"// before\nView view = catalog.registerView(ident, \"s3://bucket/warehouse/db/view/metadata/00001-abc.metadata.json\");\n// after\nView view;\ntry {\n  view = catalog.registerView(ident, metadataLocation);\n} catch (UnsupportedOperationException e) {\n  view = catalog.buildView(ident)\n      .withQueryCatalog(\"spark_catalog\")\n      .withQuery(\"spark\", \"SELECT * FROM db.tbl\")\n      .withSchema(schema)\n      .create();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["unsupported-operation","catalog","views"],"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"}