prestodb/presto · error · SchemaNotFoundException
Schema %s not found
Error message
Schema %s not found
What it means
The register_table procedure must register the table into an existing Iceberg schema. Before touching metadata files, doRegisterTable checks metadata.schemaExists(schema) and throws SchemaNotFoundException ('Schema %s not found') when the schema does not exist in the catalog. This prevents accidentally registering a table under a misspelled or not-yet-created schema.
Source
Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RegisterTableProcedure.java:109
new Argument("metadata_location", VARCHAR),
new Argument("metadata_file", VARCHAR, false, null),
new Argument("delete_data_on_drop", BOOLEAN, false, false)),
REGISTER_TABLE.bindTo(this));
}
public void registerTable(ConnectorSession clientSession, String schema, String table, String metadataLocation, String metadataFile, Boolean deleteDataOnDrop)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) {
doRegisterTable(clientSession, schema, table, metadataLocation, Optional.ofNullable(metadataFile), requireNonNull(deleteDataOnDrop, "deleteDataOnDrop is null"));
}
}
private void doRegisterTable(ConnectorSession clientSession, String schema, String table, String metadataLocation, Optional<String> metadataFile, boolean deleteDataOnDrop)
{
IcebergAbstractMetadata metadata = (IcebergAbstractMetadata) metadataFactory.create();
SchemaTableName schemaTableName = new SchemaTableName(schema, table);
if (!metadata.schemaExists(clientSession, schemaTableName.getSchemaName())) {
throw new SchemaNotFoundException(schemaTableName.getSchemaName());
}
metadataLocation = stripTrailingSlash(metadataLocation);
Path metadataDirectory = metadataLocation.endsWith(METADATA_FOLDER_NAME) ?
new Path(metadataLocation) : new Path(metadataLocation, METADATA_FOLDER_NAME);
Path metadataPath = metadataFile
.map(metadataFileName -> new Path(metadataDirectory, metadataFileName))
.orElseGet(() -> resolveLatestMetadataLocation(
clientSession,
getFileSystem(clientSession, hdfsEnvironment, schemaTableName, metadataDirectory),
metadataDirectory));
metadata.registerTable(clientSession, schemaTableName, metadataPath, deleteDataOnDrop);
}
public static FileSystem getFileSystem(ConnectorSession clientSession, HdfsEnvironment hdfsEnvironment, SchemaTableName schemaTableName, Path location)
{
HdfsContext hdfsContext = new HdfsContext(View on GitHub (pinned to 55bb57d202)
Solutions
- Create the schema first: CREATE SCHEMA iceberg.my_schema, then rerun register_table.
- Fix the schema name typo; confirm exact name via SHOW SCHEMAS FROM <catalog>.
- Ensure you are connected to the correct catalog where the schema exists.
- Check schema name casing matches exactly (some catalogs are case-sensitive).
Example fix
// before CALL system.register_table(schema => 'analyticss', table => 'events', metadata_location => '...') // after CREATE SCHEMA IF NOT EXISTS analytics; CALL system.register_table(schema => 'analytics', table => 'events', metadata_location => '...')
Defensive patterns
Strategy: validation
Validate before calling
-- ensure schema exists before register_table CREATE SCHEMA IF NOT EXISTS iceberg.analytics; SHOW SCHEMAS FROM iceberg;
Try / catch
CALL ... ; -- on SchemaNotFoundException, create schema then rerun
-- in client code:
try { registerTable(schema, table, metaLoc); }
catch ( SQLException e ) { if (e.getMessage().contains("not found")) { createSchema(schema); registerTable(schema, table, metaLoc); } } Prevention
- Run CREATE SCHEMA before any register_table call.
- Copy the schema name from SHOW SCHEMAS to avoid typos.
- Confirm you are on the catalog where the schema lives.
- Watch schema-name casing.
When it happens
Trigger: CALL system.register_table(schema => '...', table => '...', metadata_location => '...') where the schema name does not exist in the Iceberg catalog — a typo, or running the procedure before CREATE SCHEMA.
Common situations: Typo in the schema parameter; procedure executed against a different catalog than where the schema was created; schema created in another environment/tenant; case-sensitivity mismatch in schema names.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/475c9709c5d84f41.
Report an issue: GitHub.