prestodb/presto · error · SemanticException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

'%s' is a materialized view, and rename column is not supported

What it means

SemanticException thrown by RenameColumnTask when the target object resolves to a materialized view rather than a table. Presto does not support renaming columns on materialized views; the statement is rejected as unsupported. With IF EXISTS the task silently no-ops instead.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/RenameColumnTask.java:66

        return "RENAME COLUMN";
    }

    @Override
    public ListenableFuture<?> execute(RenameColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
    {
        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), metadata);
        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);
        if (!tableHandleOptional.isPresent()) {
            if (!statement.isTableExists()) {
                throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
            }
            return immediateFuture(null);
        }

        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);
        if (optionalMaterializedView.isPresent()) {
            if (!statement.isTableExists()) {
                throw new SemanticException(NOT_SUPPORTED, statement, "'%s' is a materialized view, and rename column is not supported", tableName);
            }
            return immediateFuture(null);
        }

        TableHandle tableHandle = tableHandleOptional.get();

        Identifier sourceName = statement.getSource();
        String source = metadata.normalizeIdentifier(session, tableName.getCatalogName(), sourceName.getValue());
        Identifier targetName = statement.getTarget();
        String target = metadata.normalizeIdentifier(session, tableName.getCatalogName(), targetName.getValue());

        accessControl.checkCanRenameColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);

        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
        ColumnHandle columnHandle = columnHandles.get(source);
        if (columnHandle == null) {
            if (!statement.isColumnExists()) {
                throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", source);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Drop and recreate the materialized view with the desired column names (CREATE MATERIALIZED VIEW with renamed output columns)
  2. Rename the column in the underlying base table, then refresh/recreate the materialized view
  3. Use SHOW CREATE VIEW / system metadata to confirm the object type before altering
  4. Use ALTER TABLE IF EXISTS ... only if you want a silent no-op for materialized views

Example fix

-- before
ALTER TABLE shop.mv_sales RENAME COLUMN amt TO amount; -- mv_sales is a materialized view
-- after
DROP MATERIALIZED VIEW shop.mv_sales;
CREATE MATERIALIZED VIEW shop.mv_sales AS SELECT ... AS amount, ... ;
Defensive patterns

Strategy: validation

Validate before calling

ResultSet rs = stmt.executeQuery("SELECT table_type FROM information_schema.tables WHERE table_catalog='shop' AND table_name='mv_sales'");
if (rs.next() && "MATERIALIZED VIEW".equals(rs.getString("table_type"))) {
    // recreate the materialized view instead of renaming columns
}

Try / catch

try {
    execute("ALTER TABLE shop.mv_sales RENAME COLUMN ...");
} catch (SemanticException e) {
    if (e.getCode() == NOT_SUPPORTED) {
        // fall back to DROP + CREATE MATERIALIZED VIEW with new column names
    } else throw e;
}

Prevention

When it happens

Trigger: ALTER TABLE ... RENAME COLUMN issued against a name that metadata.getMaterializedView() resolves to an existing materialized view, and statement.isTableExists() is false.

Common situations: User assumes a materialized view is a regular table; a view replaced the table after a deployment; name collision between a table and a materialized view in different contexts.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


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