{"record":{"id":"cc75a43ae2e769ee","repo":"prestodb/presto","slug":"missing-schema-cc75a4","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/TruncateTableTask.java","lineNumber":59,"sourceCode":"{\n    @Override\n    public String getName()\n    {\n        return \"TRUNCATE TABLE\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(TruncateTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);\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        if (metadataResolver.isMaterializedView(tableName)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Cannot truncate a materialized view\");\n        }\n\n        if (metadataResolver.isView(tableName)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Cannot truncate a view\");\n        }\n\n        Optional<TableHandle> tableHandle = metadata.getMetadataResolver(session).getTableHandle(tableName);\n        if (!tableHandle.isPresent()) {\n            throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n        }\n\n        accessControl.checkCanTruncateTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.truncateTable(session, tableHandle.get());","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/TruncateTableTask.java#L41-L77","documentation":"TRUNCATE TABLE validates that the target's schema exists after checking the catalog. If the schema portion of the qualified object name does not exist, a SemanticException with MISSING_SCHEMA is thrown.","triggerScenarios":"Executing TRUNCATE TABLE catalog.schema.table where schemaExists(catalogSchemaName) returns false — the schema was dropped, misspelled, or never created in the target catalog.","commonSituations":"Typos in schema names, environments where the schema doesn't exist yet, case-sensitivity mismatches, jobs pointing at the wrong catalog/schema after a config change.","solutions":["Correct the schema name (SHOW SCHEMAS FROM <catalog> to verify).","Create the schema first: CREATE SCHEMA catalog.schema.","Fix environment/config pointing at the wrong catalog/schema.","Check case-sensitivity and quoting of the schema identifier."],"exampleFix":"-- before\nTRUNCATE TABLE hive.evtls.events;\n-- after\nTRUNCATE TABLE hive.events_db.events;","handlingStrategy":"validation","validationCode":"-- before TRUNCATE\nSELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'hive' AND schema_name = 'events_db';","typeGuard":null,"tryCatchPattern":"// catch SemanticException/PrestoException with code MISSING_SCHEMA; create the schema or correct the name and retry","preventionTips":["Run SHOW SCHEMAS FROM <catalog> before scripted DDL","Verify case and quoting of schema identifiers","Ensure migrations created the target schema in every environment"],"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"}