{"record":{"id":"6ec43b3a7fcd20df","repo":"apache/iceberg","slug":"cannot-create-table-s-in-catalog-s-namespace-s","errorCode":null,"errorMessage":"Cannot create table %s in catalog %s. Namespace %s does not exist","messagePattern":"Cannot create table (.+?) in catalog (.+?)\\. Namespace (.+?) does not exist","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcTableOperations.java","lineNumber":169,"sourceCode":"            connections,\n            catalogName,\n            tableIdentifier,\n            newMetadataLocation,\n            oldMetadataLocation);\n\n    if (updatedRecords == 1) {\n      LOG.debug(\"Successfully committed to existing table: {}\", tableIdentifier);\n    } else {\n      throw new CommitFailedException(\n          \"Failed to update table %s from catalog %s\", tableIdentifier, catalogName);\n    }\n  }\n\n  private void createTable(String newMetadataLocation) throws SQLException, InterruptedException {\n    Namespace namespace = tableIdentifier.namespace();\n    if (PropertyUtil.propertyAsBoolean(catalogProperties, JdbcUtil.STRICT_MODE_PROPERTY, false)\n        && !JdbcUtil.namespaceExists(catalogName, connections, namespace)) {\n      throw new NoSuchNamespaceException(\n          \"Cannot create table %s in catalog %s. Namespace %s does not exist\",\n          tableIdentifier, catalogName, namespace);\n    }\n\n    if (schemaVersion == JdbcUtil.SchemaVersion.V1\n        && JdbcUtil.viewExists(catalogName, connections, tableIdentifier)) {\n      throw new AlreadyExistsException(\"View with same name already exists: %s\", tableIdentifier);\n    }\n\n    if (JdbcUtil.tableExists(schemaVersion, catalogName, connections, tableIdentifier)) {\n      throw new AlreadyExistsException(\"Table already exists: %s\", tableIdentifier);\n    }\n\n    int insertRecord =\n        JdbcUtil.doCommitCreateTable(\n            schemaVersion,\n            connections,\n            catalogName,","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcTableOperations.java#L151-L187","documentation":"When creating a table with the JDBC catalog in strict mode (jdbc.strict-mode=true, via JdbcUtil.STRICT_MODE_PROPERTY), createTable first verifies the parent namespace exists. If not, it throws NoSuchNamespaceException instead of silently creating the table row under an unregistered namespace. In non-strict mode this check is skipped for backward compatibility.","triggerScenarios":"catalog.createTable() called with a namespace never registered via createNamespace(); typo in namespace name; namespace dropped by another client just before table creation; strict mode newly enabled while existing namespaces predate namespace registration (V0 schema).","commonSituations":"Migration from older JDBC catalog versions where namespaces were never stored; typos in namespace passed through engine SQL (CREATE TABLE ns.tbl ...); strict mode turned on without migrating namespace rows.","solutions":["Create the namespace first: catalog.createNamespace(namespace)","Fix the namespace spelling in the table identifier","Set jdbc.strict-mode=false if legacy behavior (no namespace check) is intended, though namespaces won't be validated","For legacy catalogs, backfill namespace rows in jdbc_namespaces before enabling strict mode"],"exampleFix":"// before\ncatalog.createTable(TableIdentifier.of(\"prod.events\", \"tbl\"), schema); // ns missing\n// after\nNamespace ns = Namespace.of(\"prod\", \"events\");\nif (!catalog.namespaceExists(ns)) {\n  catalog.createNamespace(ns);\n}\ncatalog.createTable(TableIdentifier.of(ns, \"tbl\"), schema);","handlingStrategy":"validation","validationCode":"if (!catalog.namespaceExists(namespace)) { catalog.createNamespace(namespace); }","typeGuard":null,"tryCatchPattern":"try { catalog.createTable(identifier, schema); } catch (NoSuchNamespaceException e) { catalog.createNamespace(identifier.namespace()); catalog.createTable(identifier, schema); }","preventionTips":["Create namespaces as part of environment bootstrap before any createTable","Validate namespace spelling; namespaces are case-sensitive in strict mode","Only enable jdbc.strict-mode=true after backfilling namespace rows","Encapsulate 'ensure namespace then create table' in a shared helper"],"tags":["jdbc","namespace","strict-mode","catalog"],"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"}