prestodb/presto · error · PrestoException

NOT_FOUND

NOT_FOUND

Error message

Schema %s does not exist

What it means

DruidMetadata.getTableHandle throws NOT_FOUND when the requested SchemaTableName's schema does not match the Druid connector's single configured schema (druidClient.getSchema()). The Druid connector only exposes one schema, so any other schema name is reported as nonexistent. Note the same method returns null (table not found) rather than throwing when the schema matches but the table does not.

Source

Thrown at presto-druid/src/main/java/com/facebook/presto/druid/DruidMetadata.java:81

    @Inject
    public DruidMetadata(DruidClient druidClient, DruidConfig druidConfig)
    {
        this.druidClient = requireNonNull(druidClient, "druidClient is null");
        this.druidConfig = requireNonNull(druidConfig, "druidConfig is null");
    }

    @Override
    public List<String> listSchemaNames(ConnectorSession session)
    {
        return druidClient.getSchemas();
    }

    @Override
    public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)
    {
        if (!normalizeIdentifier(session, druidClient.getSchema()).equals
                (normalizeIdentifier(session, tableName.getSchemaName()))) {
            throw new PrestoException(NOT_FOUND, format("Schema %s does not exist", tableName.getSchemaName()));
        }
        return druidClient.getTables().stream()
                .filter(name -> name.equals(tableName.getTableName()))
                .map(name -> fromSchemaTableName(tableName))
                .findFirst()
                .orElse(null);
    }

    @Override
    public ConnectorTableLayoutResult getTableLayoutForConstraint(
            ConnectorSession session,
            ConnectorTableHandle table,
            Constraint<ColumnHandle> constraint,
            Optional<Set<ColumnHandle>> desiredColumns)
    {
        DruidTableHandle handle = (DruidTableHandle) table;
        ConnectorTableLayout layout = new ConnectorTableLayout(new DruidTableLayoutHandle(handle, constraint.getSummary()));
        return new ConnectorTableLayoutResult(layout, constraint.getSummary());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use the correct schema name (the connector's configured schema, typically 'druid'): SELECT * FROM druid.<table>.
  2. Check the Druid connector properties (druid.schema / metadata config) to confirm which schema is exposed.
  3. Run SHOW TABLES FROM <catalog> to list valid names before querying.
  4. If the query is generated by a tool, fix the schema qualification in the tool's connection settings.

Example fix

// before
SELECT * FROM druid.default.events;
-- after
SELECT * FROM druid.events; -- Druid connector exposes a single schema
Defensive patterns

Strategy: validation

Validate before calling

// Resolve the correct fully-qualified name before querying:
String catalog = "druid";
String schema = "druid"; // Druid connector exposes a single schema
String table = "events";
ResultSet rs = stmt.executeQuery("SELECT table_schema FROM information_schema.tables WHERE table_catalog='druid' AND table_name='" + table + "'");
if (!rs.next()) {
    throw new IllegalArgumentException("Table " + table + " not exposed by Druid connector; check schema name (got: expected druid.*)");
}

Try / catch

try {
    return query("SELECT * FROM druid." + table);
}
catch (PrestoException e) {
    if ("NOT_FOUND".equals(e.getErrorCode().getName()) && e.getMessage().contains("does not exist")) {
        throw new IllegalArgumentException("Wrong schema; Druid connector only serves its configured schema (default druid)", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Querying druid <table> where <schema> is anything other than the connector's configured schema (default 'druid'); SHOW TABLES FROM <wrong_schema>; metadata lookups from views or other connectors passing fully qualified names with a mismatched schema.

Common situations: Typo in catalog/schema qualification (e.g. SELECT * FROM druid.default.events); queries ported from other connectors that use different schema names; case-sensitivity mismatches resolved via normalizeIdentifier.

Understand the failure class

Background: NOT_FOUND error code: why tRPC, Harbor, Nacos and other libraries return 404 "not found" errors for resources that may still exist — this error's family across 11 libraries.

Related errors


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