{"record":{"id":"475c9709c5d84f41","repo":"prestodb/presto","slug":"schema-s-not-found","errorCode":null,"errorMessage":"Schema %s not found","messagePattern":"Schema (.+?) not found","errorType":"exception","errorClass":"SchemaNotFoundException","httpStatus":404,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RegisterTableProcedure.java","lineNumber":109,"sourceCode":"                        new Argument(\"metadata_location\", VARCHAR),\n                        new Argument(\"metadata_file\", VARCHAR, false, null),\n                        new Argument(\"delete_data_on_drop\", BOOLEAN, false, false)),\n                REGISTER_TABLE.bindTo(this));\n    }\n\n    public void registerTable(ConnectorSession clientSession, String schema, String table, String metadataLocation, String metadataFile, Boolean deleteDataOnDrop)\n    {\n        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) {\n            doRegisterTable(clientSession, schema, table, metadataLocation, Optional.ofNullable(metadataFile), requireNonNull(deleteDataOnDrop, \"deleteDataOnDrop is null\"));\n        }\n    }\n\n    private void doRegisterTable(ConnectorSession clientSession, String schema, String table, String metadataLocation, Optional<String> metadataFile, boolean deleteDataOnDrop)\n    {\n        IcebergAbstractMetadata metadata = (IcebergAbstractMetadata) metadataFactory.create();\n        SchemaTableName schemaTableName = new SchemaTableName(schema, table);\n        if (!metadata.schemaExists(clientSession, schemaTableName.getSchemaName())) {\n            throw new SchemaNotFoundException(schemaTableName.getSchemaName());\n        }\n\n        metadataLocation = stripTrailingSlash(metadataLocation);\n        Path metadataDirectory = metadataLocation.endsWith(METADATA_FOLDER_NAME) ?\n                new Path(metadataLocation) : new Path(metadataLocation, METADATA_FOLDER_NAME);\n        Path metadataPath = metadataFile\n                .map(metadataFileName -> new Path(metadataDirectory, metadataFileName))\n                .orElseGet(() -> resolveLatestMetadataLocation(\n                        clientSession,\n                        getFileSystem(clientSession, hdfsEnvironment, schemaTableName, metadataDirectory),\n                        metadataDirectory));\n\n        metadata.registerTable(clientSession, schemaTableName, metadataPath, deleteDataOnDrop);\n    }\n\n    public static FileSystem getFileSystem(ConnectorSession clientSession, HdfsEnvironment hdfsEnvironment, SchemaTableName schemaTableName, Path location)\n    {\n        HdfsContext hdfsContext = new HdfsContext(","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RegisterTableProcedure.java#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nCALL system.register_table(schema => 'analyticss', table => 'events', metadata_location => '...')\n// after\nCREATE SCHEMA IF NOT EXISTS analytics;\nCALL system.register_table(schema => 'analytics', table => 'events', metadata_location => '...')","handlingStrategy":"validation","validationCode":"-- ensure schema exists before register_table\nCREATE SCHEMA IF NOT EXISTS iceberg.analytics;\nSHOW SCHEMAS FROM iceberg;","typeGuard":null,"tryCatchPattern":"CALL ... ; -- on SchemaNotFoundException, create schema then rerun\n-- in client code:\ntry { registerTable(schema, table, metaLoc); }\ncatch ( SQLException e ) { if (e.getMessage().contains(\"not found\")) { createSchema(schema); registerTable(schema, table, metaLoc); } }","preventionTips":["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."],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}