{"record":{"id":"73f26635def50e54","repo":"prestodb/presto","slug":"missing-table-73f266","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/DropConstraintTask.java","lineNumber":57,"sourceCode":"\npublic class DropConstraintTask\n        implements DDLDefinitionTask<DropConstraint>\n{\n    @Override\n    public String getName()\n    {\n        return \"DROP CONSTRAINT\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(DropConstraint statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);\n        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);\n\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 drop constraint 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        accessControl.checkCanDropConstraint(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.dropConstraint(session, tableHandleOptional.get(), Optional.of(statement.getConstraintName().toString()), Optional.empty());\n        return immediateFuture(null);","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropConstraintTask.java#L39-L75","documentation":"Thrown by DropConstraintTask.execute when DROP CONSTRAINT targets a table that cannot be resolved by the catalog's metadata resolver, and the statement did not include IF EXISTS. Presto throws it before any connector-level drop work begins because there is no TableHandle for the qualified name.","triggerScenarios":"Executing 'DROP CONSTRAINT ...' (DropConstraint statement) where metadata.getMetadataResolver(session).getTableHandle(tableName) returns empty and statement.isTableExists() is false.","commonSituations":"Typo in table name; table dropped by another session; wrong catalog/schema in the qualified name; connector that does not expose the table (e.g. view mapped differently); case-sensitivity mismatches with quoted identifiers.","solutions":["Verify the fully qualified table name (catalog.schema.table) exists: SELECT * FROM system_metadata.tables or SHOW TABLES FROM schema.","Add IF EXISTS to the statement if dropping is conditional: DROP CONSTRAINT IF EXISTS ...","Check you are connected to the correct catalog and that the connector still registers the table."],"exampleFix":"// before\nDROP CONSTRAINT my_catalog.db.t1 pk_constraint;\n// after\nDROP CONSTRAINT IF EXISTS my_catalog.db.t1 pk_constraint;","handlingStrategy":"validation","validationCode":"// Presto SQL / client-side pre-check\n-- run before DROP CONSTRAINT\nSELECT table_name FROM <catalog>.information_schema.tables\nWHERE table_schema = 'db' AND table_name = 't1';\n// if empty, skip or fix the name before issuing DROP CONSTRAINT","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always qualify tables as catalog.schema.table to avoid resolution ambiguity.","Prefer DROP CONSTRAINT IF EXISTS in idempotent migration scripts.","Verify relation existence via information_schema before DDL."],"tags":["sql","metadata","missing-table"],"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"}