{"record":{"id":"0802e01dffa35e89","repo":"prestodb/presto","slug":"missing-schema-0802e0","errorCode":"MISSING_SCHEMA","errorMessage":"Schema '%s' does not exist","messagePattern":"Schema '(.+?)' 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":60,"sourceCode":"{\n    @Override\n    public String getName()\n    {\n        return \"DROP TABLE\";\n    }\n\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","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropTableTask.java#L42-L78","documentation":"Thrown by DropTableTask.execute when the catalog exists but the schema does not, and the statement does not tolerate it. The check uses metadataResolver.schemaExists(tableName.getCatalogSchemaName()) and fires before the table handle lookup.","triggerScenarios":"DROP TABLE catalog.schema.table where schemaExists is false; note the message prints tableName.getSchemaName() so the catalog prefix is absent from the error text.","commonSituations":"Typo in schema name; schema dropped by cleanup jobs; Hive database deleted externally; default-schema assumptions (e.g. script assumes 'default' exists in all catalogs).","solutions":["Run SHOW SCHEMAS FROM <catalog> and correct the schema name.","Guard with explicit existence checks in scripts before issuing DROP TABLE.","Verify the schema/database still exists in the underlying system (e.g. hive metastore)."],"exampleFix":"// before\nDROP TABLE hive.wrong_schema.events;\n// after\nDROP TABLE hive.default.events;","handlingStrategy":"validation","validationCode":"-- verify schema exists before DROP TABLE\nSELECT schema_name FROM information_schema.schemata\nWHERE catalog_name = 'hive' AND schema_name = 'default';\n-- skip the DROP TABLE if no row returned","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check both schema and table existence before destructive DDL.","Don't assume the 'default' schema exists in every catalog.","Note the error text omits the catalog prefix; read the full qualified name from your own context."],"tags":["sql","schema","missing-object"],"backgroundTag":"schema-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"}