{"record":{"id":"9d4fbf7476a1b08c","repo":"prestodb/presto","slug":"missing-table-9d4fbf","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/SetColumnDefaultTask.java","lineNumber":60,"sourceCode":"import static com.google.common.util.concurrent.Futures.immediateFuture;\n\npublic class SetColumnDefaultTask\n        implements DDLDefinitionTask<SetColumnDefault>\n{\n    @Override\n    public String getName()\n    {\n        return \"SET COLUMN DEFAULT\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(SetColumnDefault 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 set column default is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        TableHandle tableHandle = tableHandleOptional.get();\n        String columnName = metadata.normalizeIdentifier(session, tableName.getCatalogName(), statement.getColumn().getValue());\n\n        accessControl.checkCanAlterColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnDefaultTask.java#L42-L78","documentation":"ALTER TABLE ... SET DEFAULT (SetColumnDefault) resolves the target table to a TableHandle first. If the table cannot be found and the statement was not issued with IF EXISTS semantics, Presto throws MISSING_TABLE and the ALTER is skipped.","triggerScenarios":"ALTER TABLE <name> ... SET DEFAULT on a name that createQualifiedObjectName resolves but the metadata resolver has no TableHandle for, and statement.isTableExists() (IF EXISTS not given) is false.","commonSituations":"Typo in qualified table name; table dropped concurrently; running the ALTER in the wrong catalog/schema; connector lag after table creation.","solutions":["Verify the fully qualified table name exists before running the ALTER","Add IF EXISTS semantics if a silent skip is acceptable","Fix the catalog/schema context of the session"],"exampleFix":"// before\nALTER TABLE hive.default.orers ALTER COLUMN id SET DEFAULT 0;\n// after\nALTER TABLE hive.default.orders ALTER COLUMN id SET DEFAULT 0;","handlingStrategy":"validation","validationCode":"QualifiedObjectName name = createQualifiedObjectName(session, stmt, table, metadata);\nif (metadata.getMetadataResolver(session).getTableHandle(name).isEmpty()) {\n    throw new IllegalArgumentException(\"Table not found: \" + name);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return task.execute(stmt, ...);\n} catch (SemanticException e) {\n    if (e.getCode() == SemanticErrorCode.MISSING_TABLE) {\n        // skip or report missing table\n    } else {\n        throw e;\n    }\n}","preventionTips":["Verify the table with SHOW TABLES/DESCRIBE before ALTER DDL","Use IF EXISTS when the ALTER should tolerate absence","Keep migration scripts aligned with the actual environment's catalog/schema"],"tags":["sql","alter-table","table-not-found","semantic-error"],"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"}