{"record":{"id":"4c1b8e61668b89bb","repo":"prestodb/presto","slug":"not-supported-4c1b8e","errorCode":"NOT_SUPPORTED","errorMessage":"'%s' is a materialized view, and ALTER COLUMN SET/DROP NOT NULL is not supported","messagePattern":"'(.+?)' is a materialized view, and ALTER COLUMN SET/DROP NOT NULL is not supported","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java","lineNumber":72,"sourceCode":"        return \"ALTER COLUMN NOT NULL\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(AlterColumnNotNull statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), metadata);\n        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);\n        if (!tableHandleOptional.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and ALTER COLUMN SET/DROP NOT NULL is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        ConnectorId connectorId = metadata.getCatalogHandle(session, tableName.getCatalogName())\n                .orElseThrow(() -> new PrestoException(NOT_FOUND, \"Catalog does not exist: \" + tableName.getCatalogName()));\n        Set<ConnectorCapabilities> connectorCapabilities = metadata.getConnectorCapabilities(session, connectorId);\n        if (!connectorCapabilities.contains(ALTER_COLUMN) || !connectorCapabilities.contains(NOT_NULL_COLUMN_CONSTRAINT)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Catalog %s does not support ALTER COLUMN with NOT NULL\", connectorId.getCatalogName());\n        }\n\n        accessControl.checkCanAddConstraints(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        TableHandle tableHandle = tableHandleOptional.get();\n        String column = metadata.normalizeIdentifier(session, tableName.getCatalogName(), statement.getColumn().getValue());\n\n        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);\n        ColumnHandle columnHandle = columnHandles.get(column);","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java#L54-L90","documentation":"AlterColumnNotNullTask detects that the relation targeted by ALTER COLUMN ... SET/DROP NOT NULL is a materialized view, whose schema is derived from the view definition and cannot have nullability constraints altered. The target name is formatted in; it is a not-supported semantic error, not corruption.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/AlterColumnNotNullTask.java:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Recreate the materialized view with the desired nullability","Alter the underlying base table instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}