prestodb/presto · error · SemanticException
CATALOG_NOT_SPECIFIED
CATALOG_NOT_SPECIFIED
Error message
Catalog must be specified when session catalog is not set
What it means
Validation in checkCatalogAndSessionPresent for the USE statement: the statement names only a schema (USE schema) and the session has no current catalog set, so there is no catalog in which to resolve the schema.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/UseTask.java:74
QueryStateMachine stateMachine,
List<Expression> parameters,
String query)
{
Session session = stateMachine.getSession();
checkCatalogAndSessionPresent(statement, session);
checkAndSetCatalog(statement, metadata, stateMachine, session, accessControl);
checkAndSetSchema(statement, metadata, stateMachine, session, accessControl);
return immediateFuture(null);
}
private void checkCatalogAndSessionPresent(Use statement, Session session)
{
if (!statement.getCatalog().isPresent() && !session.getCatalog().isPresent()) {
throw new SemanticException(CATALOG_NOT_SPECIFIED, statement, "Catalog must be specified when session catalog is not set");
}
}
private void checkAndSetCatalog(Use statement, Metadata metadata, QueryStateMachine stateMachine, Session session, AccessControl accessControl)
{
String catalog = statement.getCatalog()
.map(Identifier::getValueLowerCase)
.orElseGet(() -> session.getCatalog().map(String::toLowerCase).get());
getConnectorIdOrThrow(session, metadata, catalog);
if (!hasCatalogAccess(session.getIdentity(), session.getAccessControlContext(), catalog, accessControl)) {
denyCatalogAccess(catalog);
}
stateMachine.setSetCatalog(catalog);
}
private void checkAndSetSchema(Use statement, Metadata metadata, QueryStateMachine stateMachine, Session session, AccessControl accessControl)
{
String catalog = statement.getCatalog()View on GitHub (pinned to 55bb57d202)
Solutions
- Wrap the USE statement execution site so that when neither the statement nor the session specifies a catalog, the error is surfaced with a corrected statement like USE catalog.schema instead of catalog-only or schema-only syntax
- Configure a default session catalog (e.g. via the client's session properties or --catalog flag) so checkCatalogAndSessionPresent always has a catalog available
- In tooling that builds USE statements programmatically, validate that a catalog is present before dispatching, or fall back to a fully qualified catalog.schema pair derived from the connection configuration
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/UseTask.java:74 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5ab9f4e19ef0b3b1.
Report an issue: GitHub.