{"record":{"id":"bf904372caead1a6","repo":"prestodb/presto","slug":"catalog-not-specified-bf9043","errorCode":"CATALOG_NOT_SPECIFIED","errorMessage":"Session catalog must be set","messagePattern":"Session catalog must be set","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java","lineNumber":118,"sourceCode":"        return value;\n    }\n\n    public static ColumnMetadata findColumnMetadata(ConnectorTableMetadata tableMetadata, String columnName)\n    {\n        for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {\n            if (columnName.equals(columnMetadata.getName())) {\n                return columnMetadata;\n            }\n        }\n        return null;\n    }\n\n    public static String createCatalogName(Session session, Node node)\n    {\n        Optional<String> sessionCatalog = session.getCatalog();\n\n        if (!sessionCatalog.isPresent()) {\n            throw new SemanticException(CATALOG_NOT_SPECIFIED, node, \"Session catalog must be set\");\n        }\n\n        return sessionCatalog.get();\n    }\n\n    public static CatalogSchemaName createCatalogSchemaName(Session session, Node node, Optional<QualifiedName> schema, Metadata metadata)\n    {\n        String catalogName = session.getCatalog().orElse(null);\n        String schemaName = session.getSchema().orElse(null);\n\n        if (schema.isPresent()) {\n            List<Identifier> parts = schema.get().getOriginalParts();\n            if (parts.size() > 2) {\n                throw new SemanticException(INVALID_SCHEMA_NAME, node, \"Too many parts in schema name: %s\", schema.get());\n            }\n            if (parts.size() == 2) {\n                catalogName = parts.get(0).getValue();\n            }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java#L100-L136","documentation":"CATALOG_NOT_SPECIFIED semantic error thrown by MetadataUtil.createCatalogName when the session has no catalog set (USE catalog not issued and no catalog-qualified name given). Presto requires a catalog to resolve an unqualified target name in catalog-management statements.","triggerScenarios":"Executing statements that call createCatalogName (e.g. CREATE SCHEMA, DROP SCHEMA, CREATE TABLE without catalog qualification) from a session where session.getCatalog() returns Optional.empty().","commonSituations":"A freshly connected client that never ran USE catalog.schema; thin clients or BI tools issuing DDL without a fully qualified name; programmatic sessions built via Session.builder without .setCatalog().","solutions":["Run USE catalog.schema before the statement","Fully qualify the name in the statement, e.g. CREATE TABLE catalog.schema.table (...)","Set the catalog in the client connection/session configuration","When constructing sessions in code, call Session.builder(...).setCatalog(...).setSchema(...)"],"exampleFix":"-- before\nCREATE SCHEMA web;\n-- after\nCREATE SCHEMA sales.web;  -- or run: USE sales.default; first","handlingStrategy":"validation","validationCode":"if (session.getCatalog().isPresent()) {\n    MetadataUtil.createCatalogName(session, node);\n} else {\n    throw new SemanticException(CATALOG_NOT_SPECIFIED, node, \"Session catalog must be set\");\n}","typeGuard":"boolean hasCatalog(Session s) { return s.getCatalog().isPresent(); }","tryCatchPattern":"try {\n    MetadataUtil.createCatalogName(session, node);\n} catch (SemanticException e) {\n    if (e.getCode() == CATALOG_NOT_SPECIFIED) {\n        // prompt user to run USE catalog.schema or qualify the name\n    }\n}","preventionTips":["Always run USE catalog.schema before DDL in interactive clients","Fully qualify names (catalog.schema.object) in generated SQL","Set catalog/schema explicitly when constructing sessions programmatically","Configure default catalog in JDBC connection URL where supported"],"tags":["presto","session","catalog","semantic-error"],"backgroundTag":"catalog-not-specified","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}