{"record":{"id":"50884d025a2001e7","repo":"prestodb/presto","slug":"not-supported-50884d","errorCode":"NOT_SUPPORTED","errorMessage":"Unsupported explain plan type %s for JSON format","messagePattern":"Unsupported explain plan type (.+?) for JSON format","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/QueryExplainer.java","lineNumber":199,"sourceCode":"        DataDefinitionTask<?> task = dataDefinitionTask.get(statement.getClass());\n        if (task != null) {\n            // todo format as json\n            return explainTask(statement, task, parameters);\n        }\n\n        Plan plan;\n        switch (planType) {\n            case IO:\n                plan = getLogicalPlan(session, statement, parameters, warningCollector, query, viewDefinitionReferences);\n                return textIOPlan(plan.getRoot(), metadata, session);\n            case LOGICAL:\n                plan = getLogicalPlan(session, statement, parameters, warningCollector, query, viewDefinitionReferences);\n                return jsonLogicalPlan(plan.getRoot(), plan.getTypes(), metadata.getFunctionAndTypeManager(), plan.getStatsAndCosts(), session);\n            case DISTRIBUTED:\n                SubPlan subPlan = getDistributedPlan(session, statement, parameters, warningCollector, query, viewDefinitionReferences);\n                return jsonDistributedPlan(subPlan, metadata.getFunctionAndTypeManager(), session);\n            default:\n                throw new PrestoException(NOT_SUPPORTED, format(\"Unsupported explain plan type %s for JSON format\", planType));\n        }\n    }\n\n    public Plan getLogicalPlan(Session session, Statement statement, List<Expression> parameters, WarningCollector warningCollector, String query, ViewDefinitionReferences viewDefinitionReferences)\n    {\n        return getLogicalPlan(session, statement, parameters, warningCollector, new PlanNodeIdAllocator(), query, viewDefinitionReferences);\n    }\n\n    public Plan getLogicalPlan(Session session, Statement statement, List<Expression> parameters, WarningCollector warningCollector, PlanNodeIdAllocator idAllocator, String query, ViewDefinitionReferences viewDefinitionReferences)\n    {\n        // analyze statement\n        Analysis analysis = session.getRuntimeStats()\n                .recordWallAndCpuTime(ANALYZE_TIME_NANOS, () -> analyze(session, statement, parameters, warningCollector, query, viewDefinitionReferences));\n\n        final VariableAllocator planVariableAllocator = new VariableAllocator();\n        LogicalPlanner logicalPlanner = new LogicalPlanner(\n                session,\n                idAllocator,","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/QueryExplainer.java#L181-L217","documentation":"QueryExplainer.getJsonPlan can only render LOGICAL or DISTRIBUTED plans in JSON explain format. If the session's explain plan type is anything else (e.g. IO, VALIDATE, or an unknown type), it falls through the switch's default branch and throws NOT_SUPPORTED, because there is no JSON rendering for that plan type.","triggerScenarios":"Running 'EXPLAIN (FORMAT JSON, TYPE <unsupported>) ...' where the explain TYPE is not LOGICAL or DISTRIBUTED, e.g. TYPE VALIDATE or TYPE IO with FORMAT JSON.","commonSituations":"Combining EXPLAIN FORMAT JSON with plan types that only have text renderings; copying an EXPLAIN invocation and changing FORMAT without adjusting TYPE.","solutions":["Use TYPE LOGICAL or TYPE DISTRIBUTED with EXPLAIN (FORMAT JSON)","Drop the TYPE clause so the default (distributed) plan type is used","Render unsupported plan types with the default text format instead of JSON"],"exampleFix":"// before\nEXPLAIN (TYPE VALIDATE, FORMAT JSON) SELECT 1;\n// after\nEXPLAIN (TYPE DISTRIBUTED, FORMAT JSON) SELECT 1;","handlingStrategy":"validation","validationCode":"EnumSet<ExplainType.Type> jsonSupported = EnumSet.of(ExplainType.Type.LOGICAL, ExplainType.Type.DISTRIBUTED);\nif (!jsonSupported.contains(explainType)) {\n    throw new IllegalArgumentException(\"FORMAT JSON only supports TYPE LOGICAL or TYPE DISTRIBUTED\");\n}","typeGuard":"boolean supportsJsonPlan(ExplainType.Type type) { return type == ExplainType.Type.LOGICAL || type == ExplainType.Type.DISTRIBUTED; }","tryCatchPattern":"try { return explainer.getJsonExplainPlan(...); } catch (PrestoException e) { if (e.getErrorCode().getCode() == NOT_SUPPORTED.toErrorCode().getCode()) { /* fall back to text format */ } else { throw e; } }","preventionTips":["Only pair FORMAT JSON with TYPE LOGICAL or TYPE DISTRIBUTED","Validate EXPLAIN options client-side before submission","Read the EXPLAIN docs matrix of supported TYPE/FORMAT combos"],"tags":["presto","sql","explain","not-supported"],"backgroundTag":"unsupported-explain-format","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"}