{"record":{"id":"003b75b2f60ff6fd","repo":"prestodb/presto","slug":"not-supported-003b75","errorCode":"NOT_SUPPORTED","errorMessage":"EXPLAIN ANALYZE doesn't support statement type: ","messagePattern":"EXPLAIN ANALYZE doesn't support statement type: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/BuiltInQueryPreparer.java","lineNumber":118,"sourceCode":"        }\n\n        Optional<QualifiedObjectName> distributedProcedureName = Optional.empty();\n        if (statement instanceof Call) {\n            QualifiedName qualifiedName = ((Call) statement).getName();\n            QualifiedObjectName qualifiedObjectName = createQualifiedObjectName(analyzerOptions.getSessionCatalogName(), analyzerOptions.getSessionSchemaName(),\n                    statement, qualifiedName, (catalogName, objectName) -> objectName);\n            if (procedureRegistry.isDistributedProcedure(\n                    new ConnectorId(qualifiedObjectName.getCatalogName()),\n                    new SchemaTableName(qualifiedObjectName.getSchemaName(), qualifiedObjectName.getObjectName()))) {\n                distributedProcedureName = Optional.of(qualifiedObjectName);\n            }\n        }\n\n        if (statement instanceof Explain && ((Explain) statement).isAnalyze()) {\n            Statement innerStatement = ((Explain) statement).getStatement();\n            Optional<QueryType> innerQueryType = StatementUtils.getQueryType(innerStatement.getClass());\n            if (!innerQueryType.isPresent() || innerQueryType.get() == QueryType.DATA_DEFINITION || innerQueryType.get() == QueryType.CONTROL) {\n                throw new PrestoException(NOT_SUPPORTED, \"EXPLAIN ANALYZE doesn't support statement type: \" + innerStatement.getClass().getSimpleName());\n            }\n        }\n        List<Expression> parameters = ImmutableList.of();\n        if (wrappedStatement instanceof Execute) {\n            parameters = ((Execute) wrappedStatement).getParameters();\n        }\n        validateParameters(statement, parameters);\n        Optional<String> formattedQuery = Optional.empty();\n        if (analyzerOptions.isLogFormattedQueryEnabled()) {\n            formattedQuery = Optional.of(getFormattedQuery(statement, parameters));\n        }\n        return new BuiltInPreparedQuery(wrappedStatement, statement, parameters, formattedQuery, prepareSql, distributedProcedureName);\n    }\n\n    private static String getFormattedQuery(Statement statement, List<Expression> parameters)\n    {\n        String formattedQuery = formatSql(\n                statement,","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/BuiltInQueryPreparer.java#L100-L136","documentation":"EXPLAIN ANALYZE actually executes the inner statement, so it only supports statements with a query type that is executable (queries/DML). If the inner statement is DATA_DEFINITION (CREATE/DROP/etc.) or CONTROL (SET/RESET etc.), or has no query type at all, prepareQuery throws NOT_SUPPORTED.","triggerScenarios":"Running 'EXPLAIN ANALYZE <statement>' where <statement> is e.g. CREATE TABLE, DROP TABLE, SET SESSION, CALL, or any statement whose class maps to no QueryType or to DATA_DEFINITION/CONTROL.","commonSituations":"Users wrapping DDL or session-control statements in EXPLAIN ANALYZE expecting a plan analysis; scripted validation tools that prefix all statements with EXPLAIN ANALYZE.","solutions":["Remove EXPLAIN ANALYZE and run the DDL/control statement directly","Use plain EXPLAIN (without ANALYZE) if only the plan is needed and the statement supports it","Only apply EXPLAIN ANALYZE to SELECT/INSERT/UPDATE/DELETE-style statements"],"exampleFix":"// before\nEXPLAIN ANALYZE CREATE TABLE t AS SELECT 1\n// after\nEXPLAIN CREATE TABLE t AS SELECT 1  -- or run the DDL directly","handlingStrategy":"validation","validationCode":"Optional<QueryType> qt = StatementUtils.getQueryType(innerStatement.getClass());\nif (!qt.isPresent() || qt.get() == QueryType.DATA_DEFINITION || qt.get() == QueryType.CONTROL) {\n    throw new IllegalArgumentException(\"EXPLAIN ANALYZE not supported for \" + innerStatement.getClass().getSimpleName());\n}","typeGuard":"boolean isExplainAnalyzeSafe(Statement s) {\n    Optional<QueryType> qt = StatementUtils.getQueryType(s.getClass());\n    return qt.isPresent() && qt.get() != QueryType.DATA_DEFINITION && qt.get() != QueryType.CONTROL;\n}","tryCatchPattern":"try {\n    preparer.prepareQuery(options, sql, params, warnings);\n} catch (PrestoException e) {\n    if (e.getMessage().startsWith(\"EXPLAIN ANALYZE doesn't support statement type\")) { /* strip EXPLAIN ANALYZE prefix and run plain statement */ }\n    throw e;\n}","preventionTips":["Only wrap SELECT/DML statements in EXPLAIN ANALYZE","Strip EXPLAIN ANALYZE prefixes from DDL/control statements in tooling","Document that EXPLAIN ANALYZE executes the statement and rejects DDL/CONTROL"],"tags":["explain-analyze","not-supported","ddl","analyzer"],"backgroundTag":"unsupported-statement-type","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"}