{"record":{"id":"e531dc5b94e6b512","repo":"prestodb/presto","slug":"not-supported-e531dc","errorCode":"NOT_SUPPORTED","errorMessage":"'%s' is a materialized view, not a table. Use DROP MATERIALIZED VIEW to drop.","messagePattern":"'(.+?)' is a materialized view, not a table\\. Use DROP MATERIALIZED VIEW to drop\\.","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/DropTableTask.java","lineNumber":74,"sourceCode":"            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        Optional<TableHandle> tableHandle = metadataResolver.getTableHandle(tableName);\n        if (!tableHandle.isPresent()) {\n            if (!statement.isExists()) {\n                throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadataResolver.getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isExists()) {\n                throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, not a table. Use DROP MATERIALIZED VIEW to drop.\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        accessControl.checkCanDropTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.dropTable(session, tableHandle.get());\n\n        return immediateFuture(null);\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":86,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropTableTask.java#L56-L86","documentation":"Thrown by DropTableTask when DROP TABLE targets a name that is actually a materialized view. Presto distinguishes materialized views from tables, so dropping requires the DROP MATERIALIZED VIEW statement; a plain DROP TABLE is rejected as NOT_SUPPORTED unless IF EXISTS was specified (in which case it silently succeeds).","triggerScenarios":"Executing `DROP TABLE mv_name` where mv_name resolves via metadataResolver.getMaterializedView(tableName) to an existing materialized view and the statement has no IF EXISTS clause.","commonSituations":"Developer created a table earlier, later replaced it with a materialized view of the same name, then runs an old DROP TABLE script; schema-automation tools emitting DROP TABLE generically without checking object type.","solutions":["Rewrite the statement as DROP MATERIALIZED VIEW <name>","If the drop is best-effort cleanup, add IF EXISTS to DROP TABLE so it no-ops instead of failing","Query system.metadata or SHOW CREATE to confirm the object type before dropping"],"exampleFix":"// before\nDROP TABLE sales_daily;\n// after\nDROP MATERIALIZED VIEW sales_daily;","handlingStrategy":"validation","validationCode":"-- determine object type before dropping\nSELECT table_type FROM system.metadata.tables\nWHERE schema_name = 'my_schema' AND table_name = 'sales_daily';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check SHOW CREATE <name> to confirm the object type before DROP","Use DROP TABLE IF EXISTS only when the target is known to be a table","Generate drop scripts from metadata queries filtered on table_type"],"tags":["presto","sql","materialized-view","semantic-error"],"backgroundTag":"wrong-object-type-drop","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"}