{"record":{"id":"9c89dd46286874fd","repo":"prestodb/presto","slug":"not-supported-9c89dd","errorCode":"NOT_SUPPORTED","errorMessage":"Cannot truncate a materialized view","messagePattern":"Cannot truncate a materialized view","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/TruncateTableTask.java","lineNumber":63,"sourceCode":"        return \"TRUNCATE TABLE\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(TruncateTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);\n\n        if (!metadataResolver.catalogExists(tableName.getCatalogName())) {\n            throw new SemanticException(MISSING_CATALOG, \"Catalog '%s' does not exist\", tableName.getCatalogName());\n        }\n\n        if (!metadataResolver.schemaExists(tableName.getCatalogSchemaName())) {\n            throw new SemanticException(MISSING_SCHEMA, statement, \"Schema '%s' does not exist\", tableName.getSchemaName());\n        }\n\n        if (metadataResolver.isMaterializedView(tableName)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Cannot truncate a materialized view\");\n        }\n\n        if (metadataResolver.isView(tableName)) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Cannot truncate a view\");\n        }\n\n        Optional<TableHandle> tableHandle = metadata.getMetadataResolver(session).getTableHandle(tableName);\n        if (!tableHandle.isPresent()) {\n            throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n        }\n\n        accessControl.checkCanTruncateTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.truncateTable(session, tableHandle.get());\n\n        return immediateFuture(null);\n    }\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/TruncateTableTask.java#L45-L81","documentation":"SemanticException (NOT_SUPPORTED) from TruncateTableTask.execute: the target name resolves to a materialized view, and truncating a materialized view is not defined; TRUNCATE only applies to base tables.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/TruncateTableTask.java:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Truncate the base tables that back the materialized view, then REFRESH the view","Drop and recreate the materialized view if the goal is to empty it","Target the base table directly instead of the materialized view"],"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"}