{"record":{"id":"44f2ab4fa42b302e","repo":"prestodb/presto","slug":"not-supported-44f2ab","errorCode":"NOT_SUPPORTED","errorMessage":"Hive metastore does not support renaming schemas","messagePattern":"Hive metastore does not support renaming schemas","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/BridgingHiveMetastore.java","lineNumber":197,"sourceCode":"    }\n\n    @Override\n    public void dropDatabase(MetastoreContext metastoreContext, String databaseName)\n    {\n        delegate.dropDatabase(metastoreContext, databaseName);\n    }\n\n    @Override\n    public void renameDatabase(MetastoreContext metastoreContext, String databaseName, String newDatabaseName)\n    {\n        org.apache.hadoop.hive.metastore.api.Database database = delegate.getDatabase(metastoreContext, databaseName)\n                .orElseThrow(() -> new SchemaNotFoundException(databaseName));\n        database.setName(newDatabaseName);\n        delegate.alterDatabase(metastoreContext, databaseName, database);\n\n        delegate.getDatabase(metastoreContext, databaseName).ifPresent(newDatabase -> {\n            if (newDatabase.getName().equals(databaseName)) {\n                throw new PrestoException(NOT_SUPPORTED, \"Hive metastore does not support renaming schemas\");\n            }\n        });\n    }\n\n    @Override\n    public MetastoreOperationResult createTable(MetastoreContext metastoreContext, Table table, PrincipalPrivileges principalPrivileges, List<TableConstraint<String>> constraints)\n    {\n        checkArgument(!table.getTableType().equals(TEMPORARY_TABLE), \"temporary tables must never be stored in the metastore\");\n        return delegate.createTable(metastoreContext, toMetastoreApiTable(table, principalPrivileges, metastoreContext.getColumnConverter()), constraints);\n    }\n\n    @Override\n    public void dropTable(MetastoreContext metastoreContext, String databaseName, String tableName, boolean deleteData)\n    {\n        delegate.dropTable(metastoreContext, databaseName, tableName, deleteData);\n    }\n\n    @Override","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/BridgingHiveMetastore.java#L179-L215","documentation":"Presto raises NOT_SUPPORTED because the Hive Thrift metastore API has no real rename operation for databases. BridgingHiveMetastore.renameDatabase emulates a rename by mutating the Database object's name and calling alterDatabase, then reads the database back; if the metastore still reports the old name, the rename silently did not take effect, so it throws this error rather than lie about success.","triggerScenarios":"Calling renameDatabase (e.g. ALTER SCHEMA x RENAME TO y) against a Thrift Hive metastore whose alterDatabase does not apply the name change — which is the behavior of standard Hive metastores.","commonSituations":"Users attempt ALTER SCHEMA ... RENAME TO on a Hive catalog; works on metastore implementations that honor name mutation but fails on stock HMS deployments, Glue-backed catalogs, or newer Thrift metastores that ignore the changed name field.","solutions":["Do not rename schemas in the Hive catalog; drop and recreate the schema with the desired name and migrate tables.","Perform the rename on a metastore implementation that supports it (or via a tool like Hive's own DDL if your metastore version allows it).","If the schema is empty, DROP SCHEMA then CREATE SCHEMA with the new name.","Check the metastore backend (e.g. AWS Glue does not support database rename) and use vendor-specific tooling instead."],"exampleFix":"// before\nALTER SCHEMA web RENAME TO web_archive;\n// after\nCREATE SCHEMA web_archive;\n-- move each table, then:\nDROP SCHEMA web;","handlingStrategy":"try-catch","validationCode":"io.prestosql.spi.security.ConnectorIdentity user = null;\n// before renaming, check the schema exists and warn about HMS limitation\nboolean exists = metadata.schemaExists(session, schemaName);","typeGuard":null,"tryCatchPattern":"try {\n    metadata.renameSchema(session, schemaName, newSchemaName);\n} catch (PrestoException e) {\n    if (StandardErrorCode.NOT_SUPPORTED.toErrorCode().equals(e.getErrorCode())) {\n        // fall back to create-new + migrate-tables workflow\n    } else {\n        throw e;\n    }\n}","preventionTips":["Assume Hive schemas are immutable in name; design pipelines to avoid schema renames","Document create+copy+drop as the sanctioned rename procedure","Test DDL against a staging metastore that mirrors production type (Glue vs stock HMS)","Catch PrestoException with NOT_SUPPORTED for any Hive rename-style DDL"],"tags":["hive","not-supported","metastore","ddl"],"backgroundTag":"unsupported-operation","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}