prestodb/presto · error · SemanticException
CATALOG_NOT_SPECIFIED
CATALOG_NOT_SPECIFIED
Error message
Session catalog must be set
What it means
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.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataUtil.java:118
return value;
}
public static ColumnMetadata findColumnMetadata(ConnectorTableMetadata tableMetadata, String columnName)
{
for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
if (columnName.equals(columnMetadata.getName())) {
return columnMetadata;
}
}
return null;
}
public static String createCatalogName(Session session, Node node)
{
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();
}View on GitHub (pinned to 55bb57d202)
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(...)
Example fix
-- before CREATE SCHEMA web; -- after CREATE SCHEMA sales.web; -- or run: USE sales.default; first
Defensive patterns
Strategy: validation
Validate before calling
if (session.getCatalog().isPresent()) {
MetadataUtil.createCatalogName(session, node);
} else {
throw new SemanticException(CATALOG_NOT_SPECIFIED, node, "Session catalog must be set");
} Type guard
boolean hasCatalog(Session s) { return s.getCatalog().isPresent(); } Try / catch
try {
MetadataUtil.createCatalogName(session, node);
} catch (SemanticException e) {
if (e.getCode() == CATALOG_NOT_SPECIFIED) {
// prompt user to run USE catalog.schema or qualify the name
}
} Prevention
- 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
When it happens
Trigger: 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().
Common situations: 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().
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/bf904372caead1a6.
Report an issue: GitHub.