{"record":{"id":"3cf21e4c9680a209","repo":"prestodb/presto","slug":"missing-schema-3cf21e","errorCode":"MISSING_SCHEMA","errorMessage":"Schema '${schemaName}' 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/sql/rewrite/ShowQueriesRewrite.java","lineNumber":244,"sourceCode":"                    node.isAnalyze(),\n                    node.isVerbose(),\n                    statement,\n                    node.getOptions());\n        }\n\n        @Override\n        protected Node visitShowTables(ShowTables showTables, Void context)\n        {\n            CatalogSchemaName schema = createCatalogSchemaName(session, showTables, showTables.getSchema(), metadata);\n\n            accessControl.checkCanShowTablesMetadata(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), schema);\n\n            if (!metadataResolver.catalogExists(schema.getCatalogName())) {\n                throw new SemanticException(MISSING_CATALOG, showTables, \"Catalog '%s' does not exist\", schema.getCatalogName());\n            }\n\n            if (!metadataResolver.schemaExists(schema)) {\n                throw new SemanticException(MISSING_SCHEMA, showTables, \"Schema '%s' does not exist\", schema.getSchemaName());\n            }\n\n            Expression predicate = equal(identifier(\"table_schema\"), new StringLiteral(schema.getSchemaName()));\n\n            Optional<String> likePattern = showTables.getLikePattern();\n            if (likePattern.isPresent()) {\n                Expression likePredicate = new LikePredicate(\n                        identifier(\"table_name\"),\n                        new StringLiteral(likePattern.get()),\n                        showTables.getEscape().map(StringLiteral::new));\n                predicate = logicalAnd(predicate, likePredicate);\n            }\n\n            return simpleQuery(\n                    selectList(aliasedName(\"table_name\", \"Table\")),\n                    from(schema.getCatalogName(), TABLE_TABLES),\n                    predicate,\n                    ordering(ascending(\"table_name\")));","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java#L226-L262","documentation":"After confirming the catalog exists, visitShowTables checks that the requested schema exists in that catalog via metadataResolver.schemaExists. If not, a SemanticException MISSING_SCHEMA is thrown naming the schema.","triggerScenarios":"Running `SHOW TABLES FROM <existing_catalog>.<schema>` where the schema does not exist in that catalog (or `SHOW TABLES` with session catalog set and a nonexistent session schema).","commonSituations":"Typo in schema name; querying a schema that was dropped; case-sensitivity assumptions (Presto schemas are case-sensitive lowercase by default); environment drift between dev and prod.","solutions":["Check the schema name spelling and case; quote it if needed.","List valid schemas with `SHOW SCHEMAS FROM <catalog>` to confirm the correct name.","Create the schema if it should exist (`CREATE SCHEMA ...`).","Point the session at the right catalog that actually contains the schema."],"exampleFix":"// before\nSHOW TABLES FROM hive.sales  -- schema missing\n// after\nSHOW SCHEMAS FROM hive;  -- find correct name, e.g.\nSHOW TABLES FROM hive.default","handlingStrategy":"validation","validationCode":"// Check schema exists before SHOW TABLES\nList<Row> rows = client.execute(\"SHOW SCHEMAS FROM \" + catalog).getRows();\nif (rows.stream().noneMatch(r -> r.get(0).equals(schemaName))) {\n    throw new IllegalArgumentException(\"Schema not found: \" + schemaName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(\"SHOW TABLES FROM \" + catalog + \".\" + schema);\n} catch (SemanticException e) {\n    if (e.getCode() == SemanticErrorCode.MISSING_SCHEMA) {\n        // fall back to default schema or report to user\n    } else throw e;\n}","preventionTips":["List schemas (SHOW SCHEMAS FROM catalog) before querying tables","Standardize on lowercase schema names to avoid case mismatches","Validate schema names in config against information_schema.schemata","Create missing schemas deliberately rather than assuming existence"],"tags":["sql","show-tables","schema","semantic-error"],"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"}