{"record":{"id":"402b3d8c1f947dc7","repo":"prestodb/presto","slug":"missing-table-402b3d","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/RenameColumnTask.java","lineNumber":58,"sourceCode":"import static com.google.common.util.concurrent.Futures.immediateFuture;\n\npublic class RenameColumnTask\n        implements DDLDefinitionTask<RenameColumn>\n{\n    @Override\n    public String getName()\n    {\n        return \"RENAME COLUMN\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(RenameColumn 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 rename column is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        TableHandle tableHandle = tableHandleOptional.get();\n\n        Identifier sourceName = statement.getSource();\n        String source = metadata.normalizeIdentifier(session, tableName.getCatalogName(), sourceName.getValue());\n        Identifier targetName = statement.getTarget();\n        String target = metadata.normalizeIdentifier(session, tableName.getCatalogName(), targetName.getValue());","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/RenameColumnTask.java#L40-L76","documentation":"SemanticException thrown by RenameColumnTask.execute when ALTER TABLE ... RENAME COLUMN targets a table that does not exist in the catalog. Presto resolves the qualified table name via the metadata resolver before performing the rename; a missing table aborts the statement. If the statement used IF EXISTS, no error is thrown and the task becomes a no-op.","triggerScenarios":"ALTER TABLE ... RENAME COLUMN where metadata.getTableHandle(tableName) returns empty and statement.isTableExists() (IF EXISTS) is false. Includes wrong catalog/schema qualification or a typo in the table name.","commonSituations":"Typo in table name; table lives in a different catalog/schema than assumed; table was dropped by another process; connecting to the wrong environment (test vs prod catalog).","solutions":["Verify the fully qualified table name (catalog.schema.table) with SHOW TABLES in the target schema","Add IF EXISTS if the drop-before-rename race is acceptable: ALTER TABLE IF EXISTS ... RENAME COLUMN","Confirm you are connected to the intended catalog (USE catalog.schema) and environment","Check permissions/environment: the connector may hide tables the current user cannot see"],"exampleFix":"-- before\nALTER TABLE shop.orders RENANE COLUMN cust_id TO customer_id; -- table 'shop.orders' typo'd\n-- after\nALTER TABLE IF EXISTS shop.orders RENAME COLUMN cust_id TO customer_id;","handlingStrategy":"validation","validationCode":"// before running ALTER TABLE ... RENAME COLUMN\nResultSet rs = stmt.executeQuery(\"SELECT table_name FROM information_schema.tables WHERE table_catalog='shop' AND table_schema='public' AND table_name='orders'\");\nboolean exists = rs.next();","typeGuard":null,"tryCatchPattern":"try {\n    execute(\"ALTER TABLE shop.orders RENAME COLUMN ... \");\n} catch (SemanticException e) {\n    if (e.getCode() == MISSING_TABLE) {\n        // skip: table absent (already migrated)\n    } else throw e;\n}","preventionTips":["Use IF EXISTS when idempotent migrations matter","Qualify names fully (catalog.schema.table) instead of relying on session defaults","Verify environment/catalog before running DDL","Run DESCRIBE or information_schema checks before altering"],"tags":["presto","ddl","missing-table","sql"],"backgroundTag":"table-not-found","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"}