prestodb/presto · error

NOT_FOUND

NOT_FOUND

Error message

Schema not found: ${schemaName}

What it means

BaseJdbcClient.createTable() checks the target schema exists via getSchemaNames() before opening a connection to create the remote table. If the schema name is absent, it throws PrestoException(NOT_FOUND, "Schema not found: ...") instead of attempting a doomed CREATE TABLE.

Source

Thrown at presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcClient.java:372

    }

    private JdbcOutputTableHandle beginWriteTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
    {
        try {
            return createTable(tableMetadata, session, generateTemporaryTableName());
        }
        catch (SQLException e) {
            throw new PrestoException(JDBC_ERROR, e);
        }
    }

    protected JdbcOutputTableHandle createTable(ConnectorTableMetadata tableMetadata, ConnectorSession session, String tableName)
            throws SQLException
    {
        SchemaTableName schemaTableName = tableMetadata.getTable();
        JdbcIdentity identity = JdbcIdentity.from(session);
        if (!getSchemaNames(session, identity).contains(schemaTableName.getSchemaName())) {
            throw new PrestoException(NOT_FOUND, "Schema not found: " + schemaTableName.getSchemaName());
        }

        try (Connection connection = connectionFactory.openConnection(identity)) {
            boolean uppercase = connection.getMetaData().storesUpperCaseIdentifiers();
            String remoteSchema = toRemoteSchemaName(session, identity, connection, schemaTableName.getSchemaName());
            String remoteTable = toRemoteTableName(session, identity, connection, remoteSchema, schemaTableName.getTableName());
            if (uppercase && !caseSensitiveNameMatchingEnabled) {
                tableName = tableName.toUpperCase(ENGLISH);
            }
            String catalog = connection.getCatalog();

            ImmutableList.Builder<String> columnNames = ImmutableList.builder();
            ImmutableList.Builder<Type> columnTypes = ImmutableList.builder();
            ImmutableList.Builder<String> columnList = ImmutableList.builder();
            for (ColumnMetadata column : tableMetadata.getColumns()) {
                String columnName = column.getName();
                if (uppercase && !caseSensitiveNameMatchingEnabled) {
                    columnName = columnName.toUpperCase(ENGLISH);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Create the schema first (CREATE SCHEMA my_schema) in the JDBC catalog or on the remote database
  2. Check the exact schema name/spelling in the CREATE TABLE statement
  3. Verify case-sensitive/case-insensitive name matching config matches how the remote DB stores identifiers
  4. Confirm you are connected to the correct database instance/catalog

Example fix

// before
CREATE TABLE missing_schema.t (id bigint);
// after
CREATE SCHEMA missing_schema;
CREATE TABLE missing_schema.t (id bigint);
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the schema exists before CREATE TABLE
ResultSet rs = connection.getMetaData().getSchemas(catalog, schemaName);
if (!rs.next()) { throw new IllegalArgumentException("Schema not found: " + schemaName); }

Try / catch

try {
    connector.createStatement().execute(createTableSql);
} catch (PrestoException e) {
    if (e.getErrorCode() == NOT_FOUND.toErrorCode()) {
        // create the schema, then retry the DDL
        connector.createStatement().execute("CREATE SCHEMA " + schemaName);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling CREATE TABLE / CREATE TABLE AS (beginWriteTable -> createTable) against a JDBC catalog with a schema name that does not exist on the remote database, or one hidden by a case-mismatch between the Presto name and the remote schema name.

Common situations: Typos in schema qualification; forgetting to create the schema on the remote database; case-sensitivity mismatch (e.g. lower/upper stored identifiers) between Presto and databases like Oracle or DB2; using a schema visible in one database instance but writing through a different JDBC connection.

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/d3a8652efd28bbc7. Report an issue: GitHub.