prestodb/presto · error · SemanticException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
'%s' is a materialized view, and alter column is not supported
What it means
Changing a column's type is only supported on real tables. When the resolved name refers to a materialized view and IF EXISTS was not specified, Presto rejects the ALTER with NOT_SUPPORTED because altering materialized view columns is not implemented.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java:77
{
return "SET COLUMN TYPE";
}
public ListenableFuture<Void> execute(SetColumnType statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);
Optional<TableHandle> tableHandle = metadata.getMetadataResolver(session).getTableHandle(tableName);
if (!tableHandle.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(SemanticErrorCode.NOT_SUPPORTED, statement, "'%s' is a materialized view, and alter column is not supported", tableName);
}
return immediateFuture(null);
}
accessControl.checkCanAlterColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);
TableHandle tableHandleOptional = tableHandle.get();
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandleOptional);
ColumnHandle column = columnHandles.get(statement.getColumnName().getValue());
if (column == null) {
throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", statement.getColumnName());
}
metadata.setColumnType(session, tableHandleOptional, column, getColumnType(statement));
return immediateFuture(null);
}
private Type getColumnType(SetColumnType statement)View on GitHub (pinned to 55bb57d202)
Solutions
- Alter the column type on the underlying base table and let the materialized view refresh/recreate accordingly
- Drop and recreate the materialized view with the corrected column type
- Use IF EXISTS if the statement should skip non-table targets silently
Example fix
// before ALTER TABLE hive.default.mv_sales ALTER COLUMN amount SET DATA TYPE DOUBLE; // after ALTER TABLE hive.default.base_sales ALTER COLUMN amount SET DATA TYPE DOUBLE;
Defensive patterns
Strategy: validation
Validate before calling
QualifiedObjectName name = createQualifiedObjectName(session, stmt, table, metadata);
if (metadata.getMetadataResolver(session).getMaterializedView(name).isPresent()) {
throw new IllegalArgumentException("Cannot ALTER COLUMN on materialized view: " + name);
} Try / catch
try {
return task.execute(stmt, ...);
} catch (SemanticException e) {
if (e.getCode() == SemanticErrorCode.NOT_SUPPORTED) {
// target the base table instead
} else {
throw e;
}
} Prevention
- Resolve materialized views to their base tables before column type changes
- Recreate materialized views when base column types change
- Keep environment schemas in sync to avoid stale DDL targets
When it happens
Trigger: ALTER TABLE <mv name> ALTER COLUMN ... SET DATA TYPE ... where getMaterializedView(tableName) returns a definition and statement.isTableExists() is false.
Common situations: Treating materialized views like tables in migration scripts; the object was replaced by a materialized view since the script was authored; schema drift between environments.
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/4cfe90512fd1e1ba.
Report an issue: GitHub.