prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Hive metastore does not support renaming schemas

What it means

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.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/BridgingHiveMetastore.java:197

    }

    @Override
    public void dropDatabase(MetastoreContext metastoreContext, String databaseName)
    {
        delegate.dropDatabase(metastoreContext, databaseName);
    }

    @Override
    public void renameDatabase(MetastoreContext metastoreContext, String databaseName, String newDatabaseName)
    {
        org.apache.hadoop.hive.metastore.api.Database database = delegate.getDatabase(metastoreContext, databaseName)
                .orElseThrow(() -> new SchemaNotFoundException(databaseName));
        database.setName(newDatabaseName);
        delegate.alterDatabase(metastoreContext, databaseName, database);

        delegate.getDatabase(metastoreContext, databaseName).ifPresent(newDatabase -> {
            if (newDatabase.getName().equals(databaseName)) {
                throw new PrestoException(NOT_SUPPORTED, "Hive metastore does not support renaming schemas");
            }
        });
    }

    @Override
    public MetastoreOperationResult createTable(MetastoreContext metastoreContext, Table table, PrincipalPrivileges principalPrivileges, List<TableConstraint<String>> constraints)
    {
        checkArgument(!table.getTableType().equals(TEMPORARY_TABLE), "temporary tables must never be stored in the metastore");
        return delegate.createTable(metastoreContext, toMetastoreApiTable(table, principalPrivileges, metastoreContext.getColumnConverter()), constraints);
    }

    @Override
    public void dropTable(MetastoreContext metastoreContext, String databaseName, String tableName, boolean deleteData)
    {
        delegate.dropTable(metastoreContext, databaseName, tableName, deleteData);
    }

    @Override

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Do not rename schemas in the Hive catalog; drop and recreate the schema with the desired name and migrate tables.
  2. 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).
  3. If the schema is empty, DROP SCHEMA then CREATE SCHEMA with the new name.
  4. Check the metastore backend (e.g. AWS Glue does not support database rename) and use vendor-specific tooling instead.

Example fix

// before
ALTER SCHEMA web RENAME TO web_archive;
// after
CREATE SCHEMA web_archive;
-- move each table, then:
DROP SCHEMA web;
Defensive patterns

Strategy: try-catch

Validate before calling

io.prestosql.spi.security.ConnectorIdentity user = null;
// before renaming, check the schema exists and warn about HMS limitation
boolean exists = metadata.schemaExists(session, schemaName);

Try / catch

try {
    metadata.renameSchema(session, schemaName, newSchemaName);
} catch (PrestoException e) {
    if (StandardErrorCode.NOT_SUPPORTED.toErrorCode().equals(e.getErrorCode())) {
        // fall back to create-new + migrate-tables workflow
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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