prestodb/presto · error · SemanticException
INVALID_SCHEMA_NAME
INVALID_SCHEMA_NAME
Error message
Too many parts in schema name: %s
What it means
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.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java:132
{
Optional<String> sessionCatalog = session.getCatalog();
if (!sessionCatalog.isPresent()) {
throw new SemanticException(CATALOG_NOT_SPECIFIED, node, "Session catalog must be set");
}
return sessionCatalog.get();
}
public static CatalogSchemaName createCatalogSchemaName(Session session, Node node, Optional<QualifiedName> schema, Metadata metadata)
{
String catalogName = session.getCatalog().orElse(null);
String schemaName = session.getSchema().orElse(null);
if (schema.isPresent()) {
List<Identifier> parts = schema.get().getOriginalParts();
if (parts.size() > 2) {
throw new SemanticException(INVALID_SCHEMA_NAME, node, "Too many parts in schema name: %s", schema.get());
}
if (parts.size() == 2) {
catalogName = parts.get(0).getValue();
}
if (catalogName == null) {
throw new SemanticException(CATALOG_NOT_SPECIFIED, node, "Catalog must be specified when session catalog is not set");
}
schemaName = metadata.normalizeIdentifier(session, catalogName, schema.get().getOriginalSuffix().getValue());
}
if (catalogName == null) {
throw new SemanticException(CATALOG_NOT_SPECIFIED, node, "Catalog must be specified when session catalog is not set");
}
if (schemaName == null) {
throw new SemanticException(SCHEMA_NOT_SPECIFIED, node, "Schema must be specified when session schema is not set");
}
return new CatalogSchemaName(catalogName, schemaName);View on GitHub (pinned to 55bb57d202)
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
Example fix
-- before CREATE SCHEMA sales.web.staging; -- after CREATE SCHEMA sales.web;
Defensive patterns
Strategy: validation
Validate before calling
QualifiedName qn = ...; // supplied schema name
if (qn.getOriginalParts().size() > 2) {
throw new IllegalArgumentException("Schema name must be at most catalog.schema: " + qn);
} Type guard
boolean isCatalogSchemaName(QualifiedName qn) { return qn.getOriginalParts().size() >= 1 && qn.getOriginalParts().size() <= 2; } Try / catch
try {
MetadataUtil.createCatalogSchemaName(session, node, schema, metadata);
} catch (SemanticException e) {
if (e.getCode() == INVALID_SCHEMA_NAME) {
// reject the statement / fix the identifier to <= 2 parts
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/a9279211428033fa.
Report an issue: GitHub.