prestodb/presto · error · SemanticException
MISSING_TABLE
MISSING_TABLE
Error message
Table '%s' does not exist
What it means
Thrown by DropTagTask when DROP TAG references a table that does not exist in the catalog. The task resolves a TableHandle via metadata.getMetadataResolver(session).getTableHandle(tableName); if absent and the statement lacks IF EXISTS (isTableExists()), it raises MISSING_TABLE.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropTagTask.java:55
public class DropTagTask
implements DDLDefinitionTask<DropTag>
{
@Override
public String getName()
{
return "DROP TAG";
}
@Override
public ListenableFuture<?> execute(DropTag 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 tag is not supported", tableName);
}
getConnectorIdOrThrow(session, metadata, tableName.getCatalogName());
accessControl.checkCanDropTag(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);
metadata.dropTag(session, tableHandleOptional.get(), statement.getTagName(), statement.isTagExists());
return immediateFuture(null);
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the table exists (SHOW TABLES / system metadata) and correct the name
- Qualify the name with the correct catalog.schema
- Add IF EXISTS if the drop is a best-effort cleanup
Example fix
// before DROP TAG ON salse_table my_tag; // after DROP TAG IF EXISTS ON sales_table my_tag;
Defensive patterns
Strategy: validation
Validate before calling
-- confirm table exists before DROP TAG SELECT * FROM system.metadata.tables WHERE schema_name = 'my_schema' AND table_name = 'sales_table';
Try / catch
try { dropTag(...); } catch (SemanticException e) { if (e.getCode() == SemanticErrorCode.MISSING_TABLE) { /* treat as no-op for idempotent cleanup */ } else { throw e; } } Prevention
- Use IF EXISTS for best-effort tag cleanup
- Qualify table names with catalog.schema to avoid wrong-schema resolution
- Source table names from metadata queries, not hardcoded literals
When it happens
Trigger: Executing `DROP TAG ON table_name ...` where getTableHandle returns Optional.empty and statement.isTableExists() is false. With IF EXISTS, the task returns success instead.
Common situations: Typo in table name; table dropped by another process before the tag removal runs; running against the wrong catalog/schema; CI cleanup scripts racing with table deletion.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d5be4977fe2d9d8c.
Report an issue: GitHub.