{"record":{"id":"a9d5644d05b7a30f","repo":"prestodb/presto","slug":"missing-schema-a9d564","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/util/MetadataUtils.java","lineNumber":90,"sourceCode":"        }\n\n        return session.getRuntimeStats().recordWallTime(\n                GET_MATERIALIZED_VIEW_TIME_NANOS,\n                () -> metadataResolver.getMaterializedView(viewName));\n    }\n\n    public static TableColumnMetadata getTableColumnMetadata(Session session, MetadataResolver metadataResolver, QualifiedObjectName tableName)\n    {\n        Optional<TableHandle> tableHandle = session.getRuntimeStats().recordWallTime(\n                GET_TABLE_HANDLE_TIME_NANOS,\n                () -> metadataResolver.getTableHandle(tableName));\n\n        if (!tableHandle.isPresent()) {\n            if (!metadataResolver.catalogExists(tableName.getCatalogName())) {\n                throw new SemanticException(MISSING_CATALOG, \"Catalog %s does not exist\", tableName.getCatalogName());\n            }\n            if (!metadataResolver.schemaExists(new CatalogSchemaName(tableName.getCatalogName(), tableName.getSchemaName()))) {\n                throw new SemanticException(MISSING_SCHEMA, \"Schema %s does not exist\", tableName.getSchemaName());\n            }\n            throw new SemanticException(MISSING_TABLE, \"Table %s does not exist\", tableName);\n        }\n\n        Map<String, ColumnHandle> columnHandles = session.getRuntimeStats().recordWallTime(\n                GET_COLUMN_HANDLE_TIME_NANOS,\n                () -> metadataResolver.getColumnHandles(tableHandle.get()));\n\n        List<ColumnMetadata> columnsMetadata = session.getRuntimeStats().recordWallTime(\n                GET_COLUMN_METADATA_TIME_NANOS,\n                () -> metadataResolver.getColumns(tableHandle.get()));\n\n        return new TableColumnMetadata(tableHandle, columnHandles, columnsMetadata);\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":106,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/util/MetadataUtils.java#L72-L106","documentation":"When resolving table metadata and no TableHandle is found, MetadataUtils checks existence in order: catalog, then schema. If the catalog exists but the schema does not, it throws SemanticException MISSING_SCHEMA with the schema name. This tells the caller the namespace itself is absent rather than just the table.","triggerScenarios":"Referencing catalog.schema.table where the catalog is configured but the schema name does not exist in that catalog, e.g. SELECT * FROM postgresql.publik.orders (typo) or querying a schema that was dropped.","commonSituations":"Typo in schema name; environment mismatch (dev vs prod schemas); schema dropped by migration while queries still reference it; wrong case-sensitive schema name for connectors like Hive or JDBC stores.","solutions":["List existing schemas: SHOW SCHEMAS FROM <catalog> and correct the name","Create the schema if intended: CREATE SCHEMA <catalog>.<schema>","Fix environment/config references pointing at the wrong schema","Check case sensitivity requirements of the connector"],"exampleFix":"// before\nSELECT * FROM postgresql.publik.orders;\n// after\nSELECT * FROM postgresql.public.orders;","handlingStrategy":"try-catch","validationCode":"// Check schema existence before resolving table metadata\nif (!metadata.listSchemaNames(session, catalogName).contains(schemaName)) {\n    throw new IllegalArgumentException(\"Unknown schema: \" + catalogName + \".\" + schemaName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    columns = MetadataUtils.getTableColumnMetadata(...);\n} catch (SemanticException e) {\n    if (e.getCode() == MISSING_SCHEMA) {\n        throw new UserError(\"Unknown schema: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Run SHOW SCHEMAS FROM <catalog> to verify names","Keep dev/prod schema names consistent via config, not hardcoding","Watch for case sensitivity in schema names per connector","Create schemas explicitly in deployment scripts"],"tags":["schema","metadata","missing","semantic"],"backgroundTag":"schema-not-found","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"}