prestodb/presto · error · SchemaNotFoundException

Schema %s not found

Error message

Schema %s not found

What it means

UnregisterTableProcedure.doUnregisterTable first checks that the schema exists via metadata.schemaExists(). When the given schema name does not exist in the catalog, it throws SchemaNotFoundException (message 'Schema %s not found') instead of attempting to unregister a table under a nonexistent namespace.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/UnregisterTableProcedure.java:77

                ImmutableList.of(
                        new Argument("schema", VARCHAR),
                        new Argument("table_name", VARCHAR)),
                UNREGISTER_TABLE.bindTo(this));
    }

    public void unregisterTable(ConnectorSession clientSession, String schema, String table)
    {
        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) {
            doUnregisterTable(clientSession, schema, table);
        }
    }

    private void doUnregisterTable(ConnectorSession clientSession, String schema, String table)
    {
        IcebergAbstractMetadata metadata = (IcebergAbstractMetadata) metadataFactory.create();
        SchemaTableName schemaTableName = new SchemaTableName(schema, table);
        if (!metadata.schemaExists(clientSession, schemaTableName.getSchemaName())) {
            throw new SchemaNotFoundException(schemaTableName.getSchemaName());
        }

        metadata.unregisterTable(clientSession, schemaTableName);
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the schema exists (SHOW SCHEMAS) and correct the schema name in the call
  2. Confirm you are connected to the intended catalog/environment
  3. If the schema was dropped, the table is already gone — no unregister needed
  4. Recreate the schema first if the intent is to also keep a namespace for other tables

Example fix

// before
CALL system.unregister_table(schema => 'sale', table => 'events'); -- schema 'sale' not found
// after
CALL system.unregister_table(schema => 'sales', table => 'events');
Defensive patterns

Strategy: validation

Validate before calling

// before calling unregister_table
SHOW SCHEMAS FROM iceberg_catalog LIKE 'myschema';
-- proceed only if a row is returned

Try / catch

try {
    runUnregisterTable(schema, table);
} catch (SchemaNotFoundException e) {
    // schema (or table) already absent; treat as no-op or correct the name
}

Prevention

When it happens

Trigger: Calling the unregister_table system procedure with a schema name that has no matching schema in the Iceberg catalog, e.g. system.unregister_table(schema => 'typo_schema', table => 't').

Common situations: Typo in the schema name; schema dropped by someone else before the call; connecting to a different catalog/environment than intended (dev vs prod); case-sensitivity mismatches in identifiers.

Related errors


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