{"record":{"id":"dfffb7ff71636244","repo":"prestodb/presto","slug":"not-supported-dfffb7","errorCode":"NOT_SUPPORTED","errorMessage":"Relation '%s' is a materialized view, not a view","messagePattern":"Relation '(.+?)' is a materialized view, not a view","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java","lineNumber":503,"sourceCode":"\n                Map<String, Object> properties = metadata.getSchemaProperties(session, catalogSchemaName);\n                Map<String, PropertyMetadata<?>> allSchemaProperties = metadata.getSchemaPropertyManager().getAllProperties().get(getConnectorIdOrThrow(session, metadata, catalogSchemaName.getCatalogName()));\n                List<Property> propertyNodes = buildProperties(\"schema \" + catalogSchemaName, INVALID_SCHEMA_PROPERTY, properties, allSchemaProperties);\n                CreateSchema createSchema = new CreateSchema(\n                        node.getName(),\n                        false,\n                        propertyNodes);\n                return singleValueQuery(\"Create Schema\", formatSql(createSchema, Optional.of(parameters)).trim());\n            }\n\n            QualifiedObjectName objectName = createQualifiedObjectName(session, node, node.getName(), metadata);\n            Optional<ViewDefinition> viewDefinition = metadataResolver.getView(objectName);\n            Optional<MaterializedViewDefinition> materializedViewDefinition = metadataResolver.getMaterializedView(objectName);\n\n            if (node.getType() == VIEW) {\n                if (!viewDefinition.isPresent()) {\n                    if (materializedViewDefinition.isPresent()) {\n                        throw new SemanticException(NOT_SUPPORTED, node, \"Relation '%s' is a materialized view, not a view\", objectName);\n                    }\n                    if (metadataResolver.getTableHandle(objectName).isPresent()) {\n                        throw new SemanticException(NOT_SUPPORTED, node, \"Relation '%s' is a table, not a view\", objectName);\n                    }\n                    throw new SemanticException(MISSING_TABLE, node, \"View '%s' does not exist\", objectName);\n                }\n\n                Query query = parseView(viewDefinition.get().getOriginalSql(), objectName, node);\n\n                accessControl.checkCanShowCreateTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), objectName);\n\n                ViewSecurity security = (viewDefinition.get().isRunAsInvoker()) ? INVOKER : DEFINER;\n                String sql = formatSql(new CreateView(getQualifiedName(node, objectName), query, false, Optional.of(security)), Optional.of(parameters)).trim();\n                return singleValueQuery(\"Create View\", sql);\n            }\n\n            if (node.getType() == MATERIALIZED_VIEW) {\n                Optional<TableHandle> tableHandle = metadataResolver.getTableHandle(objectName);","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java#L485-L521","documentation":"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.","triggerScenarios":"'SHOW CREATE VIEW <name>' on a relation that resolves to a materialized view definition (materializedViewDefinition present, viewDefinition absent).","commonSituations":"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.","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)"],"exampleFix":"// before\nSHOW CREATE VIEW sales.daily_summary;\n// after\nSHOW CREATE MATERIALIZED VIEW sales.daily_summary;","handlingStrategy":"validation","validationCode":"// Determine relation type first\nString type = queryScalar(\"SELECT table_type FROM information_schema.tables \" +\n    \"WHERE table_schema='\" + schema + \"' AND table_name='\" + name + \"'\");\nboolean isMatView = \"BASE TABLE\".equals(type) /* plus connector-specific matview listing */;","typeGuard":null,"tryCatchPattern":"try {\n    execute(\"SHOW CREATE VIEW \" + fqn);\n} catch (SemanticException e) {\n    if (e.getCode() == NOT_SUPPORTED && e.getMessage().contains(\"materialized view\")) {\n        execute(\"SHOW CREATE MATERIALIZED VIEW \" + fqn);\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["sql","semantic-analysis","materialized-view","wrong-object-type"],"backgroundTag":"wrong-relation-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}