prestodb/presto · error · SemanticException
MISSING_SCHEMA
MISSING_SCHEMA
Error message
Schema '%s' does not exist
What it means
Thrown by DropSchemaTask.execute when the catalog exists but metadataResolver.schemaExists(schema) is false and the statement omits IF EXISTS. The schema-level check runs after catalog and before permission checks (checkCanDropSchema).
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropSchemaTask.java:69
}
@Override
public ListenableFuture<?> execute(DropSchema statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
if (statement.isCascade()) {
throw new PrestoException(NOT_SUPPORTED, "CASCADE is not yet supported for DROP SCHEMA");
}
CatalogSchemaName schema = createCatalogSchemaName(session, statement, Optional.of(statement.getSchemaName()), metadata);
MetadataResolver metadataResolver = metadata.getMetadataResolver(session);
if (!metadataResolver.catalogExists(schema.getCatalogName())) {
throw new SemanticException(MISSING_CATALOG, "Catalog '%s' does not exist", schema.getCatalogName());
}
if (!metadataResolver.schemaExists(schema)) {
if (!statement.isExists()) {
throw new SemanticException(MISSING_SCHEMA, statement, "Schema '%s' does not exist", schema);
}
return immediateFuture(null);
}
accessControl.checkCanDropSchema(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), schema);
metadata.dropSchema(session, schema);
return immediateFuture(null);
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Run SHOW SCHEMAS FROM <catalog> and correct the schema name.
- Use DROP SCHEMA IF EXISTS if the drop is conditional.
- Confirm the schema wasn't already removed by another process or scheduled job.
Example fix
// before DROP SCHEMA hive.default.tmp_etl; // after DROP SCHEMA IF EXISTS hive.default.tmp_etl;
Defensive patterns
Strategy: try-catch
Validate before calling
-- pre-check schema existence SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'hive' AND schema_name = 'default';
Try / catch
// client
try {
stmt.execute("DROP SCHEMA hive.old_etl");
} catch (SQLException e) {
if (e.getMessage() != null && e.getMessage().contains("Schema") && e.getMessage().contains("does not exist")) {
// idempotent: already gone
} else { throw e; }
} Prevention
- Use DROP SCHEMA IF EXISTS in teardown jobs.
- Check SHOW SCHEMAS FROM <catalog> before schema-level DDL.
- Coordinate with other jobs that may drop schemas concurrently.
When it happens
Trigger: DROP SCHEMA catalog.schema where schemaExists returns false and statement.isExists() is false.
Common situations: Typo in schema name; schema already dropped by a teammate/job; confusion between database and schema terminology for connectors like Hive where database==schema; case-sensitivity with quoted identifiers.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/7521fddf2fcd4fd6.
Report an issue: GitHub.