prestodb/presto · error · SemanticException
MISSING_TABLE
MISSING_TABLE
Error message
Table '%s' does not exist
What it means
Thrown by AlterColumnNotNullTask.execute when ALTER TABLE ... ALTER COLUMN ... SET NOT NULL targets a table whose handle is not present in the metadata resolver and the statement lacks an IF EXISTS clause. The column-level NOT NULL alteration requires an existing table.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java:64
import static com.google.common.util.concurrent.Futures.immediateFuture;
public class AlterColumnNotNullTask
implements DDLDefinitionTask<AlterColumnNotNull>
{
@Override
public String getName()
{
return "ALTER COLUMN NOT NULL";
}
@Override
public ListenableFuture<?> execute(AlterColumnNotNull statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), 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()) {
if (!statement.isTableExists()) {
throw new SemanticException(NOT_SUPPORTED, statement, "'%s' is a materialized view, and ALTER COLUMN SET/DROP NOT NULL is not supported", tableName);
}
return immediateFuture(null);
}
ConnectorId connectorId = metadata.getCatalogHandle(session, tableName.getCatalogName())
.orElseThrow(() -> new PrestoException(NOT_FOUND, "Catalog does not exist: " + tableName.getCatalogName()));
Set<ConnectorCapabilities> connectorCapabilities = metadata.getConnectorCapabilities(session, connectorId);
if (!connectorCapabilities.contains(ALTER_COLUMN) || !connectorCapabilities.contains(NOT_NULL_COLUMN_CONSTRAINT)) {
throw new SemanticException(NOT_SUPPORTED, statement, "Catalog %s does not support ALTER COLUMN with NOT NULL", connectorId.getCatalogName());
}View on GitHub (pinned to 55bb57d202)
Solutions
- Confirm the table exists in the target catalog/schema (SHOW TABLES, SHOW CREATE TABLE)
- Fix the qualified table name in the statement
- Apply the change in the correct environment/catalog
Example fix
// before ALTER TABLE hive.default.order ALTER COLUMN id SET NOT NULL; // after ALTER TABLE hive.default.orders ALTER COLUMN id SET NOT NULL;
Defensive patterns
Strategy: validation
Validate before calling
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), metadata);
if (metadata.getMetadataResolver(session).getTableHandle(tableName).isEmpty() && !statement.isTableExists()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
} Type guard
boolean tableExists(Metadata metadata, Session session, QualifiedObjectName name) {
return metadata.getMetadataResolver(session).getTableHandle(name).isPresent();
} Try / catch
try {
executeAlterColumnNotNull(statement);
} catch (SemanticException e) {
if (e.getCode() == MISSING_TABLE) {
throw new UserError("Target table for SET NOT NULL not found; verify catalog.schema.table", e);
}
throw e;
} Prevention
- Run SHOW CREATE TABLE to confirm the exact qualified name before column-level DDL
- Keep migration scripts per environment to avoid wrong-catalog mistakes
- Use IF EXISTS when idempotent DDL is desired
- Watch for identifier case-sensitivity rules of each connector
When it happens
Trigger: `ALTER TABLE cat.schema.t ALTER COLUMN c SET NOT NULL` where the table handle is absent — table missing, misspelled, in the wrong catalog/schema, or dropped concurrently.
Common situations: Typos or stale names in migration scripts; pointing at the wrong environment's catalog; case-sensitivity mismatches for identifiers.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d3abd38298851be3.
Report an issue: GitHub.