prestodb/presto · error · SemanticException
MISSING_SCHEMA
MISSING_SCHEMA
Error message
Schema '${schemaName}' does not exist What it means
After confirming the catalog exists, visitShowTables checks that the requested schema exists in that catalog via metadataResolver.schemaExists. If not, a SemanticException MISSING_SCHEMA is thrown naming the schema.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:244
node.isAnalyze(),
node.isVerbose(),
statement,
node.getOptions());
}
@Override
protected Node visitShowTables(ShowTables showTables, Void context)
{
CatalogSchemaName schema = createCatalogSchemaName(session, showTables, showTables.getSchema(), metadata);
accessControl.checkCanShowTablesMetadata(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), schema);
if (!metadataResolver.catalogExists(schema.getCatalogName())) {
throw new SemanticException(MISSING_CATALOG, showTables, "Catalog '%s' does not exist", schema.getCatalogName());
}
if (!metadataResolver.schemaExists(schema)) {
throw new SemanticException(MISSING_SCHEMA, showTables, "Schema '%s' does not exist", schema.getSchemaName());
}
Expression predicate = equal(identifier("table_schema"), new StringLiteral(schema.getSchemaName()));
Optional<String> likePattern = showTables.getLikePattern();
if (likePattern.isPresent()) {
Expression likePredicate = new LikePredicate(
identifier("table_name"),
new StringLiteral(likePattern.get()),
showTables.getEscape().map(StringLiteral::new));
predicate = logicalAnd(predicate, likePredicate);
}
return simpleQuery(
selectList(aliasedName("table_name", "Table")),
from(schema.getCatalogName(), TABLE_TABLES),
predicate,
ordering(ascending("table_name")));View on GitHub (pinned to 55bb57d202)
Solutions
- Check the schema name spelling and case; quote it if needed.
- List valid schemas with `SHOW SCHEMAS FROM <catalog>` to confirm the correct name.
- Create the schema if it should exist (`CREATE SCHEMA ...`).
- Point the session at the right catalog that actually contains the schema.
Example fix
// before SHOW TABLES FROM hive.sales -- schema missing // after SHOW SCHEMAS FROM hive; -- find correct name, e.g. SHOW TABLES FROM hive.default
Defensive patterns
Strategy: validation
Validate before calling
// Check schema exists before SHOW TABLES
List<Row> rows = client.execute("SHOW SCHEMAS FROM " + catalog).getRows();
if (rows.stream().noneMatch(r -> r.get(0).equals(schemaName))) {
throw new IllegalArgumentException("Schema not found: " + schemaName);
} Try / catch
try {
session.execute("SHOW TABLES FROM " + catalog + "." + schema);
} catch (SemanticException e) {
if (e.getCode() == SemanticErrorCode.MISSING_SCHEMA) {
// fall back to default schema or report to user
} else throw e;
} Prevention
- List schemas (SHOW SCHEMAS FROM catalog) before querying tables
- Standardize on lowercase schema names to avoid case mismatches
- Validate schema names in config against information_schema.schemata
- Create missing schemas deliberately rather than assuming existence
When it happens
Trigger: Running `SHOW TABLES FROM <existing_catalog>.<schema>` where the schema does not exist in that catalog (or `SHOW TABLES` with session catalog set and a nonexistent session schema).
Common situations: Typo in schema name; querying a schema that was dropped; case-sensitivity assumptions (Presto schemas are case-sensitive lowercase by default); environment drift between dev and prod.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/3cf21e4c9680a209.
Report an issue: GitHub.