{"record":{"id":"a9279211428033fa","repo":"prestodb/presto","slug":"invalid-schema-name","errorCode":"INVALID_SCHEMA_NAME","errorMessage":"Too many parts in schema name: %s","messagePattern":"Too many parts in schema name: (.+?)","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java","lineNumber":132,"sourceCode":"    {\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            }\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);","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java#L114-L150","documentation":"INVALID_SCHEMA_NAME semantic error thrown by MetadataUtil.createCatalogSchemaName when a schema name supplied by the user has more than two dot-separated parts. A CatalogSchemaName can only be catalog.schema, so anything longer (e.g. a.b.c) is rejected before any catalog lookup.","triggerScenarios":"Calling createCatalogSchemaName with an Optional<QualifiedName> whose getOriginalParts().size() > 2 — i.e. statements like CREATE SCHEMA a.b.c or DROP SCHEMA x.y.z.","commonSituations":"Users pasting three-part names (table-style qualification) into CREATE/DROP SCHEMA; query builders generating over-qualified identifiers; copy-paste of a fully qualified table name into a schema position.","solutions":["Use at most two parts in the schema name: catalog.schema","Remove the extra qualifier so the name is catalog.schema or schema","If a table name was intended, use the table DDL form (CREATE TABLE catalog.schema.table) instead of schema DDL"],"exampleFix":"-- before\nCREATE SCHEMA sales.web.staging;\n-- after\nCREATE SCHEMA sales.web;","handlingStrategy":"validation","validationCode":"QualifiedName qn = ...; // supplied schema name\nif (qn.getOriginalParts().size() > 2) {\n    throw new IllegalArgumentException(\"Schema name must be at most catalog.schema: \" + qn);\n}","typeGuard":"boolean isCatalogSchemaName(QualifiedName qn) { return qn.getOriginalParts().size() >= 1 && qn.getOriginalParts().size() <= 2; }","tryCatchPattern":"try {\n    MetadataUtil.createCatalogSchemaName(session, node, schema, metadata);\n} catch (SemanticException e) {\n    if (e.getCode() == INVALID_SCHEMA_NAME) {\n        // reject the statement / fix the identifier to <= 2 parts\n    }\n}","preventionTips":["Never paste three-part table names into CREATE/DROP SCHEMA","Validate identifier part counts before dispatching schema DDL","Use table DDL (catalog.schema.table) when a table is actually intended"],"tags":["presto","schema-name","semantic-error","identifier"],"backgroundTag":"invalid-qualified-name","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"}