{"record":{"id":"dbd9818ad546dc5f","repo":"prestodb/presto","slug":"missing-table-dbd981","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/DropTableTask.java","lineNumber":66,"sourceCode":"\n    @Override\n    public ListenableFuture<?> execute(DropTable 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        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);\n\n        if (!metadataResolver.catalogExists(tableName.getCatalogName())) {\n            throw new SemanticException(MISSING_CATALOG, \"Catalog '%s' does not exist\", tableName.getCatalogName());\n        }\n\n        if (!metadataResolver.schemaExists(tableName.getCatalogSchemaName())) {\n            throw new SemanticException(MISSING_SCHEMA, statement, \"Schema '%s' does not exist\", tableName.getSchemaName());\n        }\n\n        Optional<TableHandle> tableHandle = metadataResolver.getTableHandle(tableName);\n        if (!tableHandle.isPresent()) {\n            if (!statement.isExists()) {\n                throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadataResolver.getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isExists()) {\n                throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, not a table. Use DROP MATERIALIZED VIEW to drop.\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        accessControl.checkCanDropTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.dropTable(session, tableHandle.get());\n\n        return immediateFuture(null);\n    }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropTableTask.java#L48-L84","documentation":"Thrown by DropTableTask.execute when catalog and schema exist but metadataResolver.getTableHandle(tableName) returns empty and IF EXISTS was not specified. The relation is not registered as a table with the connector (materialized views are handled separately in the following check).","triggerScenarios":"DROP TABLE where the table handle is absent and statement.isExists() is false; the name may resolve to a materialized view later, but if no table handle exists at all this error fires first.","commonSituations":"Table already dropped; typo in table name; case-sensitivity issues with quoted identifiers; table deleted in the underlying store (e.g. HDFS/metastore) so the connector no longer exposes it; targeting a view or materialized view with DROP TABLE.","solutions":["Run SHOW TABLES FROM <catalog>.<schema> and confirm the exact table name.","Use DROP TABLE IF EXISTS to make the statement idempotent.","If the target is a materialized view or view, use the matching DROP MATERIALIZED VIEW / DROP VIEW statement.","Check the underlying storage/metastore for external deletion of the table."],"exampleFix":"// before\nDROP TABLE hive.default.events_tmp;\n// after\nDROP TABLE IF EXISTS hive.default.events_tmp;","handlingStrategy":"try-catch","validationCode":"-- pre-check table existence\nSELECT table_name FROM <catalog>.information_schema.tables\nWHERE table_schema = 'default' AND table_name = 'events_tmp';","typeGuard":null,"tryCatchPattern":"// JDBC client\ntry {\n  stmt.execute(\"DROP TABLE hive.default.events_tmp\");\n} catch (SQLException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Table\") && e.getMessage().contains(\"does not exist\")) {\n    // already dropped; continue\n  } else { throw e; }\n}","preventionTips":["Make drop statements idempotent with IF EXISTS.","Distinguish tables, views, and materialized views before choosing the DROP variant.","Watch for external deletion of tables in the metastore when data is managed outside Presto."],"tags":["sql","missing-table","metadata"],"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"}