{"record":{"id":"d3abd38298851be3","repo":"prestodb/presto","slug":"missing-table-d3abd3","errorCode":"MISSING_TABLE","errorMessage":"Table '%s' does not exist","messagePattern":"Table '(.+?)' does not exist","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java","lineNumber":64,"sourceCode":"import static com.google.common.util.concurrent.Futures.immediateFuture;\n\npublic class AlterColumnNotNullTask\n        implements DDLDefinitionTask<AlterColumnNotNull>\n{\n    @Override\n    public String getName()\n    {\n        return \"ALTER COLUMN NOT NULL\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(AlterColumnNotNull statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), metadata);\n        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);\n        if (!tableHandleOptional.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and ALTER COLUMN SET/DROP NOT NULL is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        ConnectorId connectorId = metadata.getCatalogHandle(session, tableName.getCatalogName())\n                .orElseThrow(() -> new PrestoException(NOT_FOUND, \"Catalog does not exist: \" + tableName.getCatalogName()));\n        Set<ConnectorCapabilities> connectorCapabilities = metadata.getConnectorCapabilities(session, connectorId);\n        if (!connectorCapabilities.contains(ALTER_COLUMN) || !connectorCapabilities.contains(NOT_NULL_COLUMN_CONSTRAINT)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Catalog %s does not support ALTER COLUMN with NOT NULL\", connectorId.getCatalogName());\n        }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java#L46-L82","documentation":"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.","triggerScenarios":"`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.","commonSituations":"Typos or stale names in migration scripts; pointing at the wrong environment's catalog; case-sensitivity mismatches for identifiers.","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"],"exampleFix":"// before\nALTER TABLE hive.default.order ALTER COLUMN id SET NOT NULL;\n// after\nALTER TABLE hive.default.orders ALTER COLUMN id SET NOT NULL;","handlingStrategy":"validation","validationCode":"QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), metadata);\nif (metadata.getMetadataResolver(session).getTableHandle(tableName).isEmpty() && !statement.isTableExists()) {\n    throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n}","typeGuard":"boolean tableExists(Metadata metadata, Session session, QualifiedObjectName name) {\n    return metadata.getMetadataResolver(session).getTableHandle(name).isPresent();\n}","tryCatchPattern":"try {\n    executeAlterColumnNotNull(statement);\n} catch (SemanticException e) {\n    if (e.getCode() == MISSING_TABLE) {\n        throw new UserError(\"Target table for SET NOT NULL not found; verify catalog.schema.table\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["presto","ddl","missing-table","not-null"],"backgroundTag":"table-does-not-exist","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}