prestodb/presto · error · PrestoException

NOT_FOUND

NOT_FOUND

Error message

Schema [%s] does not exist

What it means

MemoryMetadata.dropSchema validates that the schema exists before removing it. If schemas.contains(schemaName) is false, it throws PrestoException NOT_FOUND saying the schema does not exist. Memory connector state is per-node/session-lifetime, so schemas vanish on restart, which frequently triggers this error.

Source

Thrown at presto-memory/src/main/java/com/facebook/presto/plugin/memory/MemoryMetadata.java:122

    public synchronized List<String> listSchemaNames(ConnectorSession session)
    {
        return ImmutableList.copyOf(schemas);
    }

    @Override
    public synchronized void createSchema(ConnectorSession session, String schemaName, Map<String, Object> properties)
    {
        if (schemas.contains(schemaName)) {
            throw new PrestoException(ALREADY_EXISTS, format("Schema [%s] already exists", schemaName));
        }
        schemas.add(schemaName);
    }

    @Override
    public synchronized void dropSchema(ConnectorSession session, String schemaName)
    {
        if (!schemas.contains(schemaName)) {
            throw new PrestoException(NOT_FOUND, format("Schema [%s] does not exist", schemaName));
        }

        boolean tablesExist = tables.values().stream()
                .anyMatch(table -> table.getSchemaName().equals(schemaName));

        if (tablesExist) {
            throw new PrestoException(SCHEMA_NOT_EMPTY, "Schema not empty: " + schemaName);
        }

        verify(schemas.remove(schemaName));
    }

    @Override
    public synchronized ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName)
    {
        Long tableId = tableIds.get(schemaTableName);
        if (tableId == null) {
            return null;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use DROP SCHEMA IF EXISTS memory.<name>
  2. Verify with SHOW SCHEMAS FROM memory that the schema currently exists
  3. Recreate the schema and its data if memory state was lost on restart
  4. Target the correct catalog where the schema actually lives

Example fix

// before
DROP SCHEMA memory.test_schema;
// after
DROP SCHEMA IF EXISTS memory.test_schema;
Defensive patterns

Strategy: try-catch

Validate before calling

// Only drop when schema currently exists
if (metadata.listSchemaNames(session, "memory").contains(schemaName)) {
    metadata.dropSchema(session, schemaName);
}

Try / catch

try {
    metadata.dropSchema(session, schemaName);
} catch (PrestoException e) {
    if (NOT_FOUND.equals(e.getErrorCode())) {
        log.info("Schema {} already gone, ignoring", schemaName);
    } else throw e;
}

Prevention

When it happens

Trigger: DROP SCHEMA memory.<name> for a schema never created, already dropped, or lost because the memory connector's in-memory state was reset (coordinator restart, different node).

Common situations: Cleanup scripts dropping schemas that were created in a previous server lifetime; running DROP on the wrong catalog (schema exists in another connector); distributed memory catalog where a worker restarted losing state.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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