prestodb/presto · error · SemanticException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
'%s' is a materialized view, and set column default is not supported
What it means
Set column default is only supported on real tables. If the resolved name refers to a materialized view and the statement did not opt into IF EXISTS behavior, Presto rejects it with NOT_SUPPORTED rather than silently applying the change to a non-table object.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnDefaultTask.java:68
return "SET COLUMN DEFAULT";
}
@Override
public ListenableFuture<?> execute(SetColumnDefault 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 set column default is not supported", tableName);
}
return immediateFuture(null);
}
TableHandle tableHandle = tableHandleOptional.get();
String columnName = metadata.normalizeIdentifier(session, tableName.getCatalogName(), statement.getColumn().getValue());
accessControl.checkCanAlterColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
ColumnHandle columnHandle = columnHandles.get(columnName);
if (columnHandle == null) {
throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", columnName);
}
ColumnMetadata columnMetadata = metadata.getColumnMetadata(session, tableHandle, columnHandle);
if (columnMetadata.isHidden()) {
throw new SemanticException(NOT_SUPPORTED, statement, "Cannot set default on hidden column");View on GitHub (pinned to 55bb57d202)
Solutions
- Run the SET DEFAULT on the underlying base table instead of the materialized view
- Drop and recreate the materialized view with the desired default on its base table
- Add IF EXISTS if the statement should silently skip non-table objects
Example fix
// before ALTER TABLE hive.default.mv_sales ALTER COLUMN region SET DEFAULT 'us'; // after ALTER TABLE hive.default.base_sales ALTER COLUMN region SET DEFAULT 'us';
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 SET DEFAULT on materialized view: " + name);
} Try / catch
try {
return task.execute(stmt, ...);
} catch (SemanticException e) {
if (e.getCode() == SemanticErrorCode.NOT_SUPPORTED) {
// redirect to the base table or skip
} else {
throw e;
}
} Prevention
- Check whether the target is a materialized view before column-level DDL
- Maintain DDL scripts against base tables, not materialized views
- Watch for tables replaced by materialized views during refactors
When it happens
Trigger: ALTER TABLE <mv name> ... SET DEFAULT where metadata.getMetadataResolver(session).getMaterializedView(tableName) returns a definition and statement.isTableExists() is false.
Common situations: Assuming a materialized view behaves like a table for DDL; the object was converted from a table to a materialized view since the script was written; name collision between a table and a view in different schemas.
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/50a0702ca00ec55c.
Report an issue: GitHub.