prestodb/presto · error · SemanticException
MISSING_SCHEMA
MISSING_SCHEMA
Error message
Schema '%s' does not exist
What it means
TRUNCATE TABLE validates that the target's schema exists after checking the catalog. If the schema portion of the qualified object name does not exist, a SemanticException with MISSING_SCHEMA is thrown.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/TruncateTableTask.java:59
{
@Override
public String getName()
{
return "TRUNCATE TABLE";
}
@Override
public ListenableFuture<?> execute(TruncateTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
MetadataResolver metadataResolver = metadata.getMetadataResolver(session);
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);
if (!metadataResolver.catalogExists(tableName.getCatalogName())) {
throw new SemanticException(MISSING_CATALOG, "Catalog '%s' does not exist", tableName.getCatalogName());
}
if (!metadataResolver.schemaExists(tableName.getCatalogSchemaName())) {
throw new SemanticException(MISSING_SCHEMA, statement, "Schema '%s' does not exist", tableName.getSchemaName());
}
if (metadataResolver.isMaterializedView(tableName)) {
throw new SemanticException(NOT_SUPPORTED, statement, "Cannot truncate a materialized view");
}
if (metadataResolver.isView(tableName)) {
throw new SemanticException(NOT_SUPPORTED, statement, "Cannot truncate a view");
}
Optional<TableHandle> tableHandle = metadata.getMetadataResolver(session).getTableHandle(tableName);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
accessControl.checkCanTruncateTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);
metadata.truncateTable(session, tableHandle.get());View on GitHub (pinned to 55bb57d202)
Solutions
- Correct the schema name (SHOW SCHEMAS FROM <catalog> to verify).
- Create the schema first: CREATE SCHEMA catalog.schema.
- Fix environment/config pointing at the wrong catalog/schema.
- Check case-sensitivity and quoting of the schema identifier.
Example fix
-- before TRUNCATE TABLE hive.evtls.events; -- after TRUNCATE TABLE hive.events_db.events;
Defensive patterns
Strategy: validation
Validate before calling
-- before TRUNCATE SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'hive' AND schema_name = 'events_db';
Try / catch
// catch SemanticException/PrestoException with code MISSING_SCHEMA; create the schema or correct the name and retry
Prevention
- Run SHOW SCHEMAS FROM <catalog> before scripted DDL
- Verify case and quoting of schema identifiers
- Ensure migrations created the target schema in every environment
When it happens
Trigger: Executing TRUNCATE TABLE catalog.schema.table where schemaExists(catalogSchemaName) returns false — the schema was dropped, misspelled, or never created in the target catalog.
Common situations: Typos in schema names, environments where the schema doesn't exist yet, case-sensitivity mismatches, jobs pointing at the wrong catalog/schema after a config change.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/cc75a43ae2e769ee.
Report an issue: GitHub.