{"record":{"id":"d5be4977fe2d9d8c","repo":"prestodb/presto","slug":"missing-table-d5be49","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/DropTagTask.java","lineNumber":55,"sourceCode":"\npublic class DropTagTask\n        implements DDLDefinitionTask<DropTag>\n{\n    @Override\n    public String getName()\n    {\n        return \"DROP TAG\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(DropTag 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            throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and drop tag is not supported\", tableName);\n        }\n\n        getConnectorIdOrThrow(session, metadata, tableName.getCatalogName());\n        accessControl.checkCanDropTag(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.dropTag(session, tableHandleOptional.get(), statement.getTagName(), statement.isTagExists());\n        return immediateFuture(null);\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":72,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropTagTask.java#L37-L72","documentation":"Thrown by DropTagTask when DROP TAG references a table that does not exist in the catalog. The task resolves a TableHandle via metadata.getMetadataResolver(session).getTableHandle(tableName); if absent and the statement lacks IF EXISTS (isTableExists()), it raises MISSING_TABLE.","triggerScenarios":"Executing `DROP TAG ON table_name ...` where getTableHandle returns Optional.empty and statement.isTableExists() is false. With IF EXISTS, the task returns success instead.","commonSituations":"Typo in table name; table dropped by another process before the tag removal runs; running against the wrong catalog/schema; CI cleanup scripts racing with table deletion.","solutions":["Verify the table exists (SHOW TABLES / system metadata) and correct the name","Qualify the name with the correct catalog.schema","Add IF EXISTS if the drop is a best-effort cleanup"],"exampleFix":"// before\nDROP TAG ON salse_table my_tag;\n// after\nDROP TAG IF EXISTS ON sales_table my_tag;","handlingStrategy":"validation","validationCode":"-- confirm table exists before DROP TAG\nSELECT * FROM system.metadata.tables\nWHERE schema_name = 'my_schema' AND table_name = 'sales_table';","typeGuard":null,"tryCatchPattern":"try { dropTag(...); } catch (SemanticException e) { if (e.getCode() == SemanticErrorCode.MISSING_TABLE) { /* treat as no-op for idempotent cleanup */ } else { throw e; } }","preventionTips":["Use IF EXISTS for best-effort tag cleanup","Qualify table names with catalog.schema to avoid wrong-schema resolution","Source table names from metadata queries, not hardcoded literals"],"tags":["presto","sql","missing-table","tag"],"backgroundTag":"object-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"}