prestodb/presto · error · SemanticException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
Relation '%s' is a materialized view, not a view
What it means
Show-queries rewrite error: SHOW CREATE VIEW (or a view-specific SHOW) was executed for a relation that is actually a materialized view. The rewrite only knows how to produce DDL for a plain view, so it refuses and names the mismatch.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:503
Map<String, Object> properties = metadata.getSchemaProperties(session, catalogSchemaName);
Map<String, PropertyMetadata<?>> allSchemaProperties = metadata.getSchemaPropertyManager().getAllProperties().get(getConnectorIdOrThrow(session, metadata, catalogSchemaName.getCatalogName()));
List<Property> propertyNodes = buildProperties("schema " + catalogSchemaName, INVALID_SCHEMA_PROPERTY, properties, allSchemaProperties);
CreateSchema createSchema = new CreateSchema(
node.getName(),
false,
propertyNodes);
return singleValueQuery("Create Schema", formatSql(createSchema, Optional.of(parameters)).trim());
}
QualifiedObjectName objectName = createQualifiedObjectName(session, node, node.getName(), metadata);
Optional<ViewDefinition> viewDefinition = metadataResolver.getView(objectName);
Optional<MaterializedViewDefinition> materializedViewDefinition = metadataResolver.getMaterializedView(objectName);
if (node.getType() == VIEW) {
if (!viewDefinition.isPresent()) {
if (materializedViewDefinition.isPresent()) {
throw new SemanticException(NOT_SUPPORTED, node, "Relation '%s' is a materialized view, not a view", objectName);
}
if (metadataResolver.getTableHandle(objectName).isPresent()) {
throw new SemanticException(NOT_SUPPORTED, node, "Relation '%s' is a table, not a view", objectName);
}
throw new SemanticException(MISSING_TABLE, node, "View '%s' does not exist", objectName);
}
Query query = parseView(viewDefinition.get().getOriginalSql(), objectName, node);
accessControl.checkCanShowCreateTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), objectName);
ViewSecurity security = (viewDefinition.get().isRunAsInvoker()) ? INVOKER : DEFINER;
String sql = formatSql(new CreateView(getQualifiedName(node, objectName), query, false, Optional.of(security)), Optional.of(parameters)).trim();
return singleValueQuery("Create View", sql);
}
if (node.getType() == MATERIALIZED_VIEW) {
Optional<TableHandle> tableHandle = metadataResolver.getTableHandle(objectName);View on GitHub (pinned to 55bb57d202)
Solutions
- Use 'SHOW CREATE MATERIALIZED VIEW <name>' instead
- Verify the object type with 'SHOW TABLES LIKE <name>' or catalog tooling before scripting
- Adjust tooling/scripts to dispatch on relation type (view vs materialized view)
Example fix
// before SHOW CREATE VIEW sales.daily_summary; // after SHOW CREATE MATERIALIZED VIEW sales.daily_summary;
Defensive patterns
Strategy: validation
Validate before calling
// Determine relation type first
String type = queryScalar("SELECT table_type FROM information_schema.tables " +
"WHERE table_schema='" + schema + "' AND table_name='" + name + "'");
boolean isMatView = "BASE TABLE".equals(type) /* plus connector-specific matview listing */; Try / catch
try {
execute("SHOW CREATE VIEW " + fqn);
} catch (SemanticException e) {
if (e.getCode() == NOT_SUPPORTED && e.getMessage().contains("materialized view")) {
execute("SHOW CREATE MATERIALIZED VIEW " + fqn);
} else { throw e; }
} Prevention
- Check relation type in information_schema before choosing SHOW CREATE variant
- Name materialized views with a distinguishable prefix
- Keep tooling aware of the matview-vs-view distinction per connector
When it happens
Trigger: 'SHOW CREATE VIEW <name>' on a relation that resolves to a materialized view definition (materializedViewDefinition present, viewDefinition absent).
Common situations: Assuming materialized views count as views; scripts written before materialized views existed in the connector; ambiguous object names in a different catalog/schema where the matview exists.
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/dfffb7ff71636244.
Report an issue: GitHub.