prestodb/presto · error · PrestoException

SCHEMA_NOT_EXISTS

SCHEMA_NOT_EXISTS

Error message

Schema '%s' does not exist

What it means

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.

Source

Thrown at presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/api/InMemorySchemaStore.java:55

    }

    @Override
    public synchronized void insert(LarkSheetsSchema schema)
    {
        String name = lower(schema.getName());
        if (schemas.containsKey(name)) {
            throw new PrestoException(LarkSheetsErrorCode.SCHEMA_ALREADY_EXISTS,
                    format("Schema '%s' already exists or created by others", name));
        }
        schemas.put(name, schema);
    }

    @Override
    public synchronized void delete(String schemaName)
    {
        String name = lower(schemaName);
        if (!schemas.containsKey(name)) {
            throw new PrestoException(LarkSheetsErrorCode.SCHEMA_NOT_EXISTS,
                    format("Schema '%s' does not exist", name));
        }
        schemas.remove(name);
    }

    @Override
    public Iterable<LarkSheetsSchema> listForUser(String user)
    {
        return schemas.values()
                .stream()
                .filter(schema -> schema.isPublicVisible() || user.equalsIgnoreCase(schema.getUser()))
                .collect(toImmutableList());
    }

    private static String lower(String name)
    {
        return name.toLowerCase(Locale.ENGLISH);
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the schema exists (listForUser or insert record) before deleting.
  2. Handle SCHEMA_NOT_EXISTS as a no-op if the goal is idempotent cleanup.
  3. Remember the store is in-memory and not durable: after a restart all schemas are gone.

Example fix

// before
store.delete("Sales");

// after
try {
    store.delete("sales");
} catch (PrestoException e) {
    if (e.getErrorCode() != LarkSheetsErrorCode.SCHEMA_NOT_EXISTS.toErrorCodeCode()) {
        throw e;
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = streamOf(store.listForUser(user)).anyMatch(s -> s.getName().equalsIgnoreCase(schemaName));
if (!exists) return; // nothing to delete

Type guard

boolean schemaExists(InMemorySchemaStore store, String name) { return streamOf(store.listForUser("")) .anyMatch(s -> s.getName().equalsIgnoreCase(name)); }

Try / catch

try { store.delete(schemaName); } catch (PrestoException e) { if (LarkSheetsErrorCode.SCHEMA_NOT_EXISTS.toErrorCode().getCode() == e.getErrorCode().getCode()) { /* idempotent no-op */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling delete(schemaName) for a name never inserted, already deleted, or spelled with different casing/whitespace than the stored name.

Common situations: 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).

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/4b62628b5f083708. Report an issue: GitHub.