{"record":{"id":"35986d177da2399f","repo":"apache/iceberg","slug":"cannot-create-view-s-in-catalog-s-namespace-s","errorCode":null,"errorMessage":"Cannot create view %s in catalog %s. Namespace %s does not exist","messagePattern":"Cannot create view (.+?) in catalog (.+?)\\. Namespace (.+?) does not exist","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java","lineNumber":177,"sourceCode":"  private void updateView(String newMetadataLocation, String oldMetadataLocation)\n      throws SQLException, InterruptedException {\n    int updatedRecords =\n        JdbcUtil.updateView(\n            connections, catalogName, viewIdentifier, newMetadataLocation, oldMetadataLocation);\n\n    if (updatedRecords == 1) {\n      LOG.debug(\"Successfully committed to existing view: {}\", viewIdentifier);\n    } else {\n      throw new CommitFailedException(\n          \"Failed to update view %s from catalog %s\", viewIdentifier, catalogName);\n    }\n  }\n\n  private void createView(String newMetadataLocation) throws SQLException, InterruptedException {\n    Namespace namespace = viewIdentifier.namespace();\n    if (PropertyUtil.propertyAsBoolean(catalogProperties, JdbcUtil.STRICT_MODE_PROPERTY, false)\n        && !JdbcUtil.namespaceExists(catalogName, connections, namespace)) {\n      throw new NoSuchNamespaceException(\n          \"Cannot create view %s in catalog %s. Namespace %s does not exist\",\n          viewIdentifier, catalogName, namespace);\n    }\n\n    if (JdbcUtil.tableExists(JdbcUtil.SchemaVersion.V1, catalogName, connections, viewIdentifier)) {\n      throw new AlreadyExistsException(\"Table with same name already exists: %s\", viewIdentifier);\n    }\n\n    if (JdbcUtil.viewExists(catalogName, connections, viewIdentifier)) {\n      throw new AlreadyExistsException(\"View already exists: %s\", viewIdentifier);\n    }\n\n    int insertRecord =\n        JdbcUtil.doCommitCreateView(\n            connections, catalogName, namespace, viewIdentifier, newMetadataLocation);\n\n    if (insertRecord == 1) {\n      LOG.debug(\"Successfully committed to new view: {}\", viewIdentifier);","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java#L159-L195","documentation":"When creating a new view, if strict mode is enabled (jdbc.strict-mode=true in catalog properties) and the target namespace does not exist in the JDBC catalog, createView throws NoSuchNamespaceException instead of creating the view under an implicitly-existing namespace row.","triggerScenarios":"Committing a brand-new view (base == null) with catalog property jdbc.strict-mode=true while the parent namespace has never been created via createNamespace.","commonSituations":"Enabling strict mode on an existing catalog whose namespaces were created under non-strict behavior; writing views through a fresh JDBC catalog without initializing namespaces; a typo in the namespace name.","solutions":["Create the namespace first: catalog.createNamespace(namespace) (or catalog.buildCreateNamespace(...)) before creating the view","Disable strict mode by setting jdbc.strict-mode=false in the JDBC catalog properties if implicit namespace handling is acceptable","Verify the namespace spelling in the view identifier matches an existing namespace","Check namespace existence before commit: catalog.namespaceExists(namespace)"],"exampleFix":"// before\ncreateView(\"my_ns.my_view\"); // strict mode, namespace missing\n// after\nif (!catalog.namespaceExists(Namespace.of(\"my_ns\"))) {\n  catalog.createNamespace(Namespace.of(\"my_ns\"));\n}\ncreateView(\"my_ns.my_view\");","handlingStrategy":"validation","validationCode":"if (!catalog.namespaceExists(namespace)) {\n  catalog.createNamespace(namespace);\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.buildView(id)...create();\n} catch (NoSuchNamespaceException e) {\n  catalog.createNamespace(id.namespace());\n  catalog.buildView(id)...create();\n}","preventionTips":["Create namespaces as part of environment setup before creating views","Check jdbc.strict-mode setting in catalog properties and align workflows with it","Validate namespace spelling before commits"],"tags":["jdbc","namespace","strict-mode","view-creation"],"backgroundTag":"entity-not-found","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"}