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
SHOW GRANTS without an ON <table> clause needs a catalog to enumerate grants across: either the statement names one, the table clause provided one, or the session has a default catalog. If catalogName is still null after those checks, visitShowGrants throws CATALOG_NOT_SPECIFIED.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:294
!metadataResolver.getTableHandle(qualifiedTableName).isPresent()) {
throw new SemanticException(MISSING_TABLE, showGrants, "Table '%s' does not exist", tableName);
}
catalogName = qualifiedTableName.getCatalogName();
accessControl.checkCanShowTablesMetadata(
session.getRequiredTransactionId(),
session.getIdentity(),
session.getAccessControlContext(),
new CatalogSchemaName(catalogName, qualifiedTableName.getSchemaName()));
predicate = Optional.of(combineConjuncts(
equal(identifier("table_schema"), new StringLiteral(qualifiedTableName.getSchemaName())),
equal(identifier("table_name"), new StringLiteral(qualifiedTableName.getObjectName()))));
}
else {
if (catalogName == null) {
throw new SemanticException(CATALOG_NOT_SPECIFIED, showGrants, "Catalog must be specified when session catalog is not set");
}
Set<String> allowedSchemas = listSchemas(session, metadata, accessControl, catalogName);
for (String schema : allowedSchemas) {
accessControl.checkCanShowTablesMetadata(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), new CatalogSchemaName(catalogName, schema));
}
}
return simpleQuery(
selectList(
aliasedName("grantor", "Grantor"),
aliasedName("grantor_type", "Grantor Type"),
aliasedName("grantee", "Grantee"),
aliasedName("grantee_type", "Grantee Type"),
aliasedName("table_catalog", "Catalog"),
aliasedName("table_schema", "Schema"),
aliasedName("table_name", "Table"),
aliasedName("privilege_type", "Privilege"),View on GitHub (pinned to 55bb57d202)
Solutions
- Qualify the statement: `SHOW GRANTS FROM <catalog>` (or `SHOW GRANTS ON <catalog>.<schema>.<table>`).
- Set the session catalog first: `USE <catalog>.<schema>`.
- Configure the client/driver to connect with a default catalog.
- In generated SQL, always emit an explicit catalog for administrative SHOW statements.
Example fix
// before SHOW GRANTS -- session catalog unset // after SHOW GRANTS FROM hive
Defensive patterns
Strategy: validation
Validate before calling
if (session.getCatalog() == null && !statementSpecifiesCatalog(showGrantsSql)) {
throw new IllegalArgumentException("Set a session catalog or add FROM <catalog> to SHOW GRANTS");
} Try / catch
try {
session.execute("SHOW GRANTS");
} catch (SemanticException e) {
if (e.getCode() == SemanticErrorCode.CATALOG_NOT_SPECIFIED) {
session.execute("USE " + defaultCatalog + "." + defaultSchema);
session.execute("SHOW GRANTS");
} else throw e;
} Prevention
- Always specify the catalog explicitly in administrative SHOW statements
- Configure a default catalog in client/driver connection settings
- In automation, run USE catalog.schema before catalog-scoped statements
- Emit fully qualified SQL from generated queries
When it happens
Trigger: Running bare `SHOW GRANTS` while the session has no catalog set (no USE, no default catalog at connect time) and the statement does not include a catalog-qualified schema/table.
Common situations: Fresh client sessions without a default catalog; BI tools issuing SHOW GRANTS before any USE; scripts assuming a session catalog configured on the server.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/ef95474f98861981.
Report an issue: GitHub.