{"record":{"id":"39d26bd34b98c24d","repo":"prestodb/presto","slug":"not-supported-39d26b","errorCode":"NOT_SUPPORTED","errorMessage":"'%s' is a materialized view, and create branch is not supported","messagePattern":"'(.+?)' is a materialized view, and create branch is not supported","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/CreateBranchTask.java","lineNumber":77,"sourceCode":"    @Override\n    public String getName()\n    {\n        return \"CREATE BRANCH\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(CreateBranch statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);\n        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);\n\n        if (statement.isTableExists() && !tableHandleOptional.isPresent()) {\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and create branch is not supported\", tableName);\n        }\n\n        getConnectorIdOrThrow(session, metadata, tableName.getCatalogName());\n        accessControl.checkCanCreateBranch(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        if (statement.isReplace() && statement.isIfNotExists()) {\n            throw new SemanticException(NOT_SUPPORTED, statement,\n                    \"Cannot specify both OR REPLACE and IF NOT EXISTS in CREATE BRANCH statement\");\n        }\n\n        Optional<ConnectorTableVersion> tableVersion = Optional.empty();\n\n        if (statement.getTableVersion().isPresent()) {\n            TableVersionExpression tableVersionExpr = statement.getTableVersion().get();\n            Expression stateExpr = tableVersionExpr.getStateExpression();\n            TableVersionExpression.TableVersionType tableVersionType = tableVersionExpr.getTableVersionType();\n            TableVersionExpression.TableVersionOperator tableVersionOperator = tableVersionExpr.getTableVersionOperator();\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/CreateBranchTask.java#L59-L95","documentation":"CREATE BRANCH was issued against a materialized view, which Presto does not support branching. The task resolves the target name via metadata.getMetadataResolver(session).getMaterializedView(tableName); if a materialized view definition exists there, it throws SemanticException NOT_SUPPORTED.","triggerScenarios":"Executing CREATE BRANCH <name> where the target qualified object name refers to a materialized view rather than a table; passing a materialized view name by mistake in migration or snapshotting scripts.","commonSituations":"Automation that snapshots 'all tables' but enumerates materialized views too; users assuming branches work on any relation in branch-capable catalogs (e.g. lakehouse connectors); renamed tables replaced by materialized views keeping the same name.","solutions":["Issue CREATE BRANCH against a base table, not a materialized view","If a branch of the view's source is needed, branch the underlying table instead","List relations and confirm the type first (SHOW TABLES / system metadata) to avoid targeting a materialized view","Adjust automation to skip materialized-view entries when generating CREATE BRANCH statements"],"exampleFix":"// before\nCREATE BRANCH mv_audit_2024 FROM reporting.mv_daily_sales;\n// after\nCREATE BRANCH audit_2024 FROM reporting.fact_sales; -- base table, not the materialized view","handlingStrategy":"validation","validationCode":"// before CREATE BRANCH, confirm target is a table\nboolean isMatView = metadataResolver.getMaterializedView(tableName).isPresent();\nif (isMatView) throw new IllegalArgumentException(\"Cannot branch materialized view: \" + tableName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter materialized views out of automated branch-creation pipelines","Check relation type via metadata before branching","Document that branching applies to tables only in your tooling"],"tags":["not-supported","materialized-view","branching"],"backgroundTag":"operation-not-supported-on-relation","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}