{"record":{"id":"4b62628b5f083708","repo":"prestodb/presto","slug":"schema-not-exists","errorCode":"SCHEMA_NOT_EXISTS","errorMessage":"Schema '%s' does not exist","messagePattern":"Schema '(.+?)' does not exist","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/api/InMemorySchemaStore.java","lineNumber":55,"sourceCode":"    }\n\n    @Override\n    public synchronized void insert(LarkSheetsSchema schema)\n    {\n        String name = lower(schema.getName());\n        if (schemas.containsKey(name)) {\n            throw new PrestoException(LarkSheetsErrorCode.SCHEMA_ALREADY_EXISTS,\n                    format(\"Schema '%s' already exists or created by others\", name));\n        }\n        schemas.put(name, schema);\n    }\n\n    @Override\n    public synchronized void delete(String schemaName)\n    {\n        String name = lower(schemaName);\n        if (!schemas.containsKey(name)) {\n            throw new PrestoException(LarkSheetsErrorCode.SCHEMA_NOT_EXISTS,\n                    format(\"Schema '%s' does not exist\", name));\n        }\n        schemas.remove(name);\n    }\n\n    @Override\n    public Iterable<LarkSheetsSchema> listForUser(String user)\n    {\n        return schemas.values()\n                .stream()\n                .filter(schema -> schema.isPublicVisible() || user.equalsIgnoreCase(schema.getUser()))\n                .collect(toImmutableList());\n    }\n\n    private static String lower(String name)\n    {\n        return name.toLowerCase(Locale.ENGLISH);\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/api/InMemorySchemaStore.java#L37-L73","documentation":"InMemorySchemaStore.delete throws SCHEMA_NOT_EXISTS when the requested schema name (lowercased) is not present in the store. Deletion only succeeds for schemas previously inserted into this store instance.","triggerScenarios":"Calling delete(schemaName) for a name never inserted, already deleted, or spelled with different casing/whitespace than the stored name.","commonSituations":"DROP SCHEMA on a schema that was dropped by another session/node; typo'd or differently-cased schema name; store was restarted and is empty (in-memory state lost).","solutions":["Verify the schema exists (listForUser or insert record) before deleting.","Handle SCHEMA_NOT_EXISTS as a no-op if the goal is idempotent cleanup.","Remember the store is in-memory and not durable: after a restart all schemas are gone."],"exampleFix":"// before\nstore.delete(\"Sales\");\n\n// after\ntry {\n    store.delete(\"sales\");\n} catch (PrestoException e) {\n    if (e.getErrorCode() != LarkSheetsErrorCode.SCHEMA_NOT_EXISTS.toErrorCodeCode()) {\n        throw e;\n    }\n}","handlingStrategy":"try-catch","validationCode":"boolean exists = streamOf(store.listForUser(user)).anyMatch(s -> s.getName().equalsIgnoreCase(schemaName));\nif (!exists) return; // nothing to delete","typeGuard":"boolean schemaExists(InMemorySchemaStore store, String name) { return streamOf(store.listForUser(\"\")) .anyMatch(s -> s.getName().equalsIgnoreCase(name)); }","tryCatchPattern":"try { store.delete(schemaName); } catch (PrestoException e) { if (LarkSheetsErrorCode.SCHEMA_NOT_EXISTS.toErrorCode().getCode() == e.getErrorCode().getCode()) { /* idempotent no-op */ } else { throw e; } }","preventionTips":["Make deletes idempotent by swallowing SCHEMA_NOT_EXISTS.","Check casing: the store lowercases names, so compare with equalsIgnoreCase.","Remember in-memory state is lost on restart — don't assume schemas persist."],"tags":["schema","not-found","presto"],"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"}