{"record":{"id":"3db0062a35d03745","repo":"apache/iceberg","slug":"cannot-s-view-s-because-the-underlying-catalog","errorCode":null,"errorMessage":"Cannot %s view %s because the underlying catalog %s","messagePattern":"Cannot (.+?) view (.+?) because the underlying catalog (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":584,"sourceCode":"    if (null != asViewCatalog) {\n      try {\n        org.apache.iceberg.view.View icebergView = asViewCatalog.loadView(buildIdentifier(ident));\n        return SparkView.toView(catalogName, icebergView);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\n    }\n\n    throw new NoSuchViewException(ident);\n  }\n\n  @Override\n  public View createView(Identifier ident, View view)\n      throws ViewAlreadyExistsException, NoSuchNamespaceException {\n    try {\n      return commitView(ident, view, ViewCommit.CREATE);\n    } catch (NoSuchViewException e) {\n      throw unexpectedViewCommitException(\"create\", ident, \"reported that the view is missing\", e);\n    }\n  }\n\n  @Override\n  public View replaceView(Identifier ident, View view) throws NoSuchViewException {\n    try {\n      return commitView(ident, view, ViewCommit.REPLACE);\n    } catch (NoSuchNamespaceException e) {\n      throw unexpectedViewCommitException(\n          \"replace\", ident, \"reported that the namespace is missing\", e);\n    } catch (ViewAlreadyExistsException e) {\n      throw unexpectedViewCommitException(\n          \"replace\", ident, \"reported that the view already exists\", e);\n    }\n  }\n\n  @Override\n  public View createOrReplaceView(Identifier ident, View view)","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L566-L602","documentation":"SparkCatalog.createView commits a view CREATE to the underlying Iceberg catalog. If the catalog unexpectedly reports NoSuchViewException during creation (it said the view is missing when that should not happen for CREATE), createView wraps it via unexpectedViewCommitException with message 'Cannot %s view %s because the underlying catalog %s'. This signals an inconsistent or non-compliant underlying catalog, not a normal 'already exists' outcome.","triggerScenarios":"Calling SparkCatalog.createView(ident, view) when commitView raises NoSuchViewException — i.e. the delegate catalog rejects the CREATE commit by claiming the view does not exist, violating the expected commit protocol for ViewCommit.CREATE.","commonSituations":"Custom or third-party ViewCatalog implementations with incorrect commit semantics; catalogs in a stale or inconsistent state; version mismatches between the Spark Iceberg runtime and the catalog service; views dropped concurrently so CREATE's post-condition checks fail unexpectedly.","solutions":["Inspect the cause (NoSuchViewException) and verify the underlying catalog's commit behavior for CREATE","Retry the createView call once the catalog state is consistent","Test the catalog implementation against the Iceberg ViewCatalog contract; fix the catalog if custom","Upgrade the catalog client/runtime to matching versions to rule out protocol skew"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify the namespace and that the catalog supports view commits before calling\nNamespace ns = ident.namespace();\nif (!catalog.namespaceExists(ns)) { catalog.createNamespace(ns); }","typeGuard":null,"tryCatchPattern":"try { return catalog.createView(ident, view); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot create view\")) { /* inspect cause, retry or recreate namespace */ } throw e; }","preventionTips":["Use a ViewCatalog-compliant catalog implementation","Recreate namespaces before creating views","Coordinate concurrent view operations on the same identifier","Keep Spark Iceberg runtime and catalog server versions aligned"],"tags":["spark","views","catalog","commit"],"backgroundTag":"invalid-state-transition","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}