{"record":{"id":"b148af6cc837fdbe","repo":"prestodb/presto","slug":"not-supported-b148af","errorCode":"NOT_SUPPORTED","errorMessage":"Cross-catalog materialized views require legacy_materialized_views=false.","messagePattern":"Cross-catalog materialized views require legacy_materialized_views=false\\.","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/CreateMaterializedViewTask.java","lineNumber":153,"sourceCode":"                session,\n                metadata,\n                parameterLookup);\n\n        ConnectorTableMetadata viewMetadata = new ConnectorTableMetadata(\n                toSchemaTableName(viewName),\n                columnMetadata,\n                properties,\n                statement.getComment());\n\n        String sql = getFormattedSql(statement.getQuery(), sqlParser, Optional.of(parameters));\n\n        List<String> baseTableCatalogsList = new ArrayList<>();\n        Map<String, QualifiedObjectName> uniqueTables = new LinkedHashMap<>();\n        analysis.getTableNodes().forEach(table -> {\n            QualifiedObjectName tableName = createQualifiedObjectName(session, table, table.getName(), metadata);\n            if (!viewName.getCatalogName().equals(tableName.getCatalogName())) {\n                if (isLegacyMaterializedViews(session)) {\n                    throw new SemanticException(\n                            NOT_SUPPORTED,\n                            statement,\n                            \"Cross-catalog materialized views require legacy_materialized_views=false.\");\n                }\n                if (!isCrossCatalogEnabled(properties)) {\n                    throw new SemanticException(NOT_SUPPORTED,\n                            format(\"Cross-catalog materialized views are not enabled. \" +\n                                            \"Materialized view %s cannot be created from a base table %s in a different catalog %s.\",\n                                    viewName, tableName, tableName.getCatalogName()));\n                }\n            }\n            String key = String.format(\"%s.%s.%s\", tableName.getCatalogName(), tableName.getSchemaName(), tableName.getObjectName());\n            uniqueTables.putIfAbsent(key, tableName);\n        });\n        List<SchemaTableName> baseTables = uniqueTables.values().stream()\n                .map(tableName -> {\n                    baseTableCatalogsList.add(tableName.getCatalogName());\n                    return toSchemaTableName(tableName);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/CreateMaterializedViewTask.java#L135-L171","documentation":"Presto throws this SemanticException(NOT_SUPPORTED) from CreateMaterializedViewTask.execute when a CREATE MATERIALIZED VIEW references a base table in a different catalog while the session still runs in legacy materialized-view mode. Legacy mode does not support cross-catalog MVs, so the statement is rejected up front. Setting legacy_materialized_views=false unlocks the newer cross-catalog path (which additionally requires cross-catalog support to be enabled).","triggerScenarios":"CREATE MATERIALIZED VIEW whose analysis.getTableNodes() contains a base table whose catalog differs from the target view's catalog, while session property legacy_materialized_views=true.","commonSituations":"Clusters upgraded from older Presto where legacy_materialized_views defaults to true; users defining an MV in catalog A over a table in catalog B (e.g. hive.ods feeding an iceberg reporting MV); session property set globally in a legacy config.","solutions":["Set the session property: SET SESSION legacy_materialized_views = false; before running CREATE MATERIALIZED VIEW.","Disable the legacy default in the coordinator's config properties or for the relevant resource group/session so cross-catalog MVs are allowed.","Rewrite the MV so all base tables live in the same catalog as the MV if you must stay in legacy mode.","Verify cross-catalog support is enabled for the connector (isCrossCatalogEnabled) after disabling legacy mode."],"exampleFix":"-- before\nSET SESSION legacy_materialized_views = true;\nCREATE MATERIALIZED VIEW reporting.mv AS SELECT * FROM hive.ods.events;\n\n-- after\nSET SESSION legacy_materialized_views = false;\nCREATE MATERIALIZED VIEW reporting.mv AS SELECT * FROM hive.ods.events;","handlingStrategy":"validation","validationCode":"boolean legacy = session.getProperty(SESSION_LEGACY_MATERIALIZED_VIEWS, Boolean.class);\nboolean crossCatalog = baseTables.stream().anyMatch(t -> !t.getCatalogName().equals(viewName.getCatalogName()));\nif (crossCatalog && legacy) {\n    throw new IllegalStateException(\"Disable legacy_materialized_views before creating cross-catalog MVs\");\n}","typeGuard":"boolean isCrossCatalogPlan(Session session, QualifiedObjectName viewName, Collection<QualifiedObjectName> baseTables) {\n    return baseTables.stream().anyMatch(t -> !t.getCatalogName().equals(viewName.getCatalogName()))\n        && isLegacyMaterializedViews(session);\n}","tryCatchPattern":"try {\n    createMaterializedView(session, statement);\n} catch (SemanticException e) {\n    if (e.getCode() == NOT_SUPPORTED && e.getMessage().contains(\"legacy_materialized_views\")) {\n        // retry with legacy_materialized_views=false session\n    } else {\n        throw e;\n    }\n}","preventionTips":["Set legacy_materialized_views=false in cluster defaults before authoring cross-catalog MVs","Keep MV definitions and their base tables in the same catalog where possible","Add a DDL lint step that flags cross-catalog MV references","Document the session property requirement for teams migrating off legacy MVs"],"tags":["presto","materialized-view","not-supported","cross-catalog","session-property"],"backgroundTag":"cross-catalog-materialized-view-not-supported","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"}