{"record":{"id":"540ee7b8aba3f47e","repo":"apache/iceberg","slug":"namespace-does-not-exist-s-540ee7","errorCode":null,"errorMessage":"Namespace does not exist: %s","messagePattern":"Namespace does not exist: (.+?)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java","lineNumber":340,"sourceCode":"            identifier.name());\n\n    if (deletedRecords == 0) {\n      LOG.info(\"Skipping drop, table does not exist: {}\", identifier);\n      return false;\n    }\n\n    if (purge && lastMetadata != null) {\n      CatalogUtil.dropTableData(ops.io(), lastMetadata);\n    }\n\n    LOG.info(\"Dropped table: {}\", identifier);\n    return true;\n  }\n\n  @Override\n  public List<TableIdentifier> listTables(Namespace namespace) {\n    if (!namespaceExists(namespace)) {\n      throw new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace);\n    }\n\n    return fetch(\n        row ->\n            JdbcUtil.stringToTableIdentifier(\n                row.getString(JdbcUtil.TABLE_NAMESPACE), row.getString(JdbcUtil.TABLE_NAME)),\n        (schemaVersion == JdbcUtil.SchemaVersion.V1)\n            ? JdbcUtil.V1_LIST_TABLE_SQL\n            : JdbcUtil.V0_LIST_TABLE_SQL,\n        catalogName,\n        JdbcUtil.namespaceToString(namespace));\n  }\n\n  @Override\n  public void renameTable(TableIdentifier from, TableIdentifier to) {\n    if (from.equals(to)) {\n      return;\n    }","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java#L322-L358","documentation":"NoSuchNamespaceException thrown by JdbcCatalog.listTables when the given Namespace has no rows in the iceberg_namespace_properties table — i.e. the namespace was never created or was dropped. listTables refuses to return an empty list for unknown namespaces so callers can distinguish 'empty' from 'nonexistent'.","triggerScenarios":"Calling catalog.listTables(Namespace.of(\"...\")) for a namespace that was never created via createNamespace, was already dropped, or whose name differs in case from what was created.","commonSituations":"Typo or case mismatch in the namespace name, querying before createNamespace in bootstrap code, a catalog pointed at the wrong database/warehouse, or a concurrent drop between namespaceExists and the query.","solutions":["Create the namespace first with catalog.createNamespace(namespace)","Verify the namespace name spelling and case (Postgres stores it as given)","Confirm you are connected to the JDBC database that actually holds the namespace","Use listNamespaces() to discover existing namespace names before listing tables"],"exampleFix":"// before\nList<TableIdentifier> tables = catalog.listTables(Namespace.of(\"reporting\"));\n// after\nif (catalog.namespaceExists(Namespace.of(\"reporting\"))) {\n  List<TableIdentifier> tables = catalog.listTables(Namespace.of(\"reporting\"));\n} else {\n  catalog.createNamespace(Namespace.of(\"reporting\"));\n}","handlingStrategy":"try-catch","validationCode":"Namespace ns = Namespace.of(\"reporting\");\nif (!catalog.namespaceExists(ns)) {\n  catalog.createNamespace(ns);\n}","typeGuard":"boolean safeToList(Catalog c, Namespace ns) { return c.namespaceExists(ns); }","tryCatchPattern":"try {\n  tables = catalog.listTables(ns);\n} catch (NoSuchNamespaceException e) {\n  catalog.createNamespace(ns);\n  tables = List.of();\n}","preventionTips":["Call createNamespace before listTables in bootstrap code","Verify namespace spelling/case against catalog.listNamespaces()","Confirm the catalog points at the intended JDBC database","Handle NoSuchNamespaceException explicitly to distinguish empty vs missing"],"tags":["jdbc","namespace","not-found","catalog"],"backgroundTag":"resource-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"}