{"record":{"id":"d7727dfd0c2332b1","repo":"prestodb/presto","slug":"schema-not-specified","errorCode":"SCHEMA_NOT_SPECIFIED","errorMessage":"Schema must be specified when session schema is not set","messagePattern":"Schema must be specified when session schema is not set","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java","lineNumber":147,"sourceCode":"        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            }\n            if (catalogName == null) {\n                throw new SemanticException(CATALOG_NOT_SPECIFIED, node, \"Catalog must be specified when session catalog is not set\");\n            }\n            schemaName = metadata.normalizeIdentifier(session, catalogName, schema.get().getOriginalSuffix().getValue());\n        }\n\n        if (catalogName == null) {\n            throw new SemanticException(CATALOG_NOT_SPECIFIED, node, \"Catalog must be specified when session catalog is not set\");\n        }\n        if (schemaName == null) {\n            throw new SemanticException(SCHEMA_NOT_SPECIFIED, node, \"Schema must be specified when session schema is not set\");\n        }\n\n        return new CatalogSchemaName(catalogName, schemaName);\n    }\n\n    public static QualifiedObjectName createQualifiedObjectName(Session session, Node node, QualifiedName name, Metadata metadata)\n    {\n        BiFunction<String, String, String> normalizer = (catalogName, objectName) -> metadata.normalizeIdentifier(session, catalogName, objectName);\n        return MetadataUtils.createQualifiedObjectName(session.getCatalog(), session.getSchema(), node, name, normalizer);\n    }\n\n    public static Optional<CatalogMetadata> getOptionalCatalogMetadata(Session session, TransactionManager transactionManager, String catalogName)\n    {\n        return transactionManager.getOptionalCatalogMetadata(session.getRequiredTransactionId(), catalogName);\n    }\n\n    public static Optional<TableHandle> getOptionalTableHandle(Session session, TransactionManager transactionManager, QualifiedObjectName table, Optional<ConnectorTableVersion> tableVersion)\n    {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java#L129-L165","documentation":"SCHEMA_NOT_SPECIFIED semantic error thrown at the end of createCatalogSchemaName when a catalog name was resolved (from session or the given name) but no schema could be determined — the given name had no schema part and the session schema is unset. Presto requires a concrete catalog.schema pair.","triggerScenarios":"Calling createCatalogSchemaName with a name or session that yields catalogName != null but schemaName == null, e.g. session has catalog set but no schema, and the statement passes no schema qualifier.","commonSituations":"Session connected with catalog only (no USE of a schema) executing unqualified schema DDL; JDBC URL with catalog but no schema; clients that assume a default schema exists.","solutions":["Add the schema to the statement: CREATE SCHEMA catalog.schema","Run USE catalog.schema to set both session catalog and schema","Set the schema in the JDBC URL or session configuration"],"exampleFix":"-- before (catalog set, no session schema)\nCREATE SCHEMA staging;\n-- after\nCREATE SCHEMA sales.staging;","handlingStrategy":"validation","validationCode":"if (session.getSchema().isEmpty() && (schema.isEmpty() || schema.get().getOriginalParts().size() < 2)) {\n    throw new IllegalArgumentException(\"Schema must be set in session or supplied as catalog.schema\");\n}","typeGuard":"boolean schemaResolvable(Session s, java.util.Optional<QualifiedName> schema) {\n    return s.getSchema().isPresent() || (schema.isPresent() && schema.get().getOriginalParts().size() >= 1);\n}","tryCatchPattern":"try {\n    MetadataUtil.createCatalogSchemaName(session, node, schema, metadata);\n} catch (SemanticException e) {\n    if (e.getCode() == SCHEMA_NOT_SPECIFIED) {\n        // require USE catalog.schema or a qualified name before retry\n    }\n}","preventionTips":["Qualify schema DDL as catalog.schema","Run USE catalog.schema at session start","Set schema in JDBC URL or client defaults instead of relying on implicit defaults"],"tags":["presto","schema","session","semantic-error"],"backgroundTag":"schema-not-specified","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}