{"record":{"id":"3a2d25c9d2cc7cf4","repo":"apache/iceberg","slug":"registering-views-is-not-supported-3a2d25","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/ViewSessionCatalog.java","lineNumber":137,"sourceCode":"   * not cached, do nothing.\n   *\n   * @param identifier a view identifier\n   */\n  default void invalidateView(SessionCatalog.SessionContext context, TableIdentifier identifier) {}\n\n  /**\n   * Register a view if it does not exist.\n   *\n   * @param context session context\n   * @param ident 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(\n      SessionCatalog.SessionContext context, TableIdentifier ident, 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  void initialize(String name, Map<String, String> properties);\n}\n","sourceCodeStart":119,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java#L119-L152","documentation":"ViewSessionCatalog is the SessionCatalog variant of ViewCatalog; its registerView default method throws UnsupportedOperationException because session-aware catalog wrappers are not required to support registering views from metadata files. Only implementations that explicitly override it will work.","triggerScenarios":"Calling sessionCatalog.registerView(context, ident, metadataFileLocation) (typically via CatalogManager/Spark session catalog dispatch) against a wrapped catalog that does not override the method.","commonSituations":"Registering an existing view's metadata file through a session-aware catalog path (e.g., Spark 4 session catalog adapters) where the underlying catalog lacks registerView; code paths shared with table registration that assume parity between registerTable and registerView.","solutions":["Bypass the session wrapper and call registerView directly on the underlying ViewCatalog if it supports view registration.","Recreate the view in the target catalog with createView instead of registering its metadata file.","Upgrade the catalog implementation to a version that implements registerView.","Wrap the call in try-catch for UnsupportedOperationException and report that view registration is unavailable for this catalog.","Implement registerView in the custom session catalog, delegating to the inner catalog."],"exampleFix":"// before\nView view = sessionCatalog.registerView(context, ident, metadataLocation);\n// after\nView view;\ntry {\n  view = sessionCatalog.registerView(context, ident, metadataLocation);\n} catch (UnsupportedOperationException e) {\n  throw new IllegalArgumentException(\n      \"Catalog \" + name + \" does not support registering views; recreate the view instead\", e);\n}","handlingStrategy":"try-catch","validationCode":"boolean supports = !(catalog.getClass().getName().contains(\"HiveCatalog\")); // or consult docs\ncatalog.views().forEach(v -> System.out.println(v.name())); // catalog must at least implement ViewCatalog","typeGuard":"boolean supportsViewRegistration(Catalog catalog) {\n  return !(catalog instanceof ViewCatalog) ? false\n      : !catalog.getClass().get superclass. getMethod(\"registerView\", TableIdentifier.class, String.class)\n          .getDeclaringClass().isInterface();\n}","tryCatchPattern":"try {\n  view = catalog.registerView(ident, metadataLocation);\n} catch (UnsupportedOperationException e) {\n  throw new UnsupportedOperationException(\n      \"View registration is not supported by \" + catalog.name(), e);\n}","preventionTips":["Check the catalog implementation's docs before assuming registerView works.","Prefer createView-based migration over metadata-file registration when unsure.","Feature-test the method via reflection in generic tooling.","Keep catalog implementations upgraded to versions that implement registerView."],"tags":["unsupported-operation","catalog","views","session-catalog"],"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"}