prestodb/presto · error · SemanticException
MISSING_TABLE
MISSING_TABLE
Error message
Table '%s' does not exist
What it means
DropBranchTask.execute resolves the target table handle via metadata.getMetadataResolver(session).getTableHandle. When no handle is returned the table does not exist; unless IF EXISTS was specified, it throws SemanticException(MISSING_TABLE). With IF EXISTS the statement is a no-op.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropBranchTask.java:55
public class DropBranchTask
implements DDLDefinitionTask<DropBranch>
{
@Override
public String getName()
{
return "DROP BRANCH";
}
@Override
public ListenableFuture<?> execute(DropBranch statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);
Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);
if (!tableHandleOptional.isPresent()) {
if (!statement.isTableExists()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
return immediateFuture(null);
}
Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);
if (optionalMaterializedView.isPresent()) {
throw new SemanticException(NOT_SUPPORTED, statement, "'%s' is a materialized view, and drop branch is not supported", tableName);
}
getConnectorIdOrThrow(session, metadata, tableName.getCatalogName());
accessControl.checkCanDropBranch(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);
metadata.dropBranch(session, tableHandleOptional.get(), statement.getBranchName(), statement.isBranchExists());
return immediateFuture(null);
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the table with SHOW TABLES FROM <catalog>.<schema> and correct the name.
- Add IF EXISTS: DROP BRANCH IF EXISTS ... ON <table> to make the drop idempotent.
- Confirm the fully qualified name points at the intended catalog and schema.
Example fix
// before DROP BRANCH b1 ON hive.default.events; -- table doesn't exist // after (idempotent) DROP BRANCH IF EXISTS b1 ON hive.default.events;
Defensive patterns
Strategy: validation
Validate before calling
-- Confirm the table exists before DROP BRANCH SELECT table_name FROM information_schema.tables WHERE table_catalog = 'hive' AND table_schema = 'default' AND table_name = 'events';
Try / catch
try {
session.execute(`DROP BRANCH ${branch} ON ${table}`);
} catch (e) {
if (/Table '.*' does not exist/.test(e.message)) {
log.warn(`Skipping drop branch: ${table} missing`);
return; // or use IF EXISTS next time
}
throw e;
} Prevention
- Use DROP BRANCH IF EXISTS in idempotent scripts and migrations.
- Verify table names with SHOW TABLES before destructive DDL.
- Fully qualify table names (catalog.schema.table) to avoid wrong-target resolution.
When it happens
Trigger: Executing DROP BRANCH ON <table> (without IF EXISTS) where the qualified table name cannot be resolved to a TableHandle by the connector.
Common situations: Typo in table name; wrong catalog/schema qualification; table dropped concurrently by another session; querying a branch/tag name as if it were a table; connector metadata lag after ingestion.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/cab8d204891bf408.
Report an issue: GitHub.