{"record":{"id":"f06eb801230706e1","repo":"prestodb/presto","slug":"unsupported-explain-type","errorCode":null,"errorMessage":"Unsupported EXPLAIN type: ","messagePattern":"Unsupported EXPLAIN type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java","lineNumber":1352,"sourceCode":"\n        throw new IllegalArgumentException(\"Unsupported EXPLAIN format: \" + context.value.getText());\n    }\n\n    @Override\n    public Node visitExplainType(SqlBaseParser.ExplainTypeContext context)\n    {\n        switch (context.value.getType()) {\n            case SqlBaseLexer.LOGICAL:\n                return new ExplainType(getLocation(context), ExplainType.Type.LOGICAL);\n            case SqlBaseLexer.DISTRIBUTED:\n                return new ExplainType(getLocation(context), ExplainType.Type.DISTRIBUTED);\n            case SqlBaseLexer.VALIDATE:\n                return new ExplainType(getLocation(context), ExplainType.Type.VALIDATE);\n            case SqlBaseLexer.IO:\n                return new ExplainType(getLocation(context), ExplainType.Type.IO);\n        }\n\n        throw new IllegalArgumentException(\"Unsupported EXPLAIN type: \" + context.value.getText());\n    }\n\n    @Override\n    public Node visitShowTables(SqlBaseParser.ShowTablesContext context)\n    {\n        return new ShowTables(\n                getLocation(context),\n                Optional.ofNullable(context.qualifiedName())\n                        .map(this::getQualifiedName),\n                getTextIfPresent(context.pattern)\n                        .map(AstBuilder::unquote),\n                getTextIfPresent(context.escape)\n                        .map(AstBuilder::unquote));\n    }\n\n    @Override\n    public Node visitShowSchemas(SqlBaseParser.ShowSchemasContext context)\n    {","sourceCodeStart":1334,"sourceCodeEnd":1370,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java#L1334-L1370","documentation":"AstBuilder.visitExplainType throws this IllegalArgumentException when an EXPLAIN TYPE clause carries a token other than LOGICAL, DISTRIBUTED, VALIDATE or IO. Like the format variant, the grammar only produces known tokens, so this indicates a fork/grammar mismatch or an unhandled enum case.","triggerScenarios":"Running 'EXPLAIN (TYPE <x>) ...' where the type token is not one of the four handled values, or a parser build where the grammar's ExplainTypeContext accepts tokens AstBuilder does not switch on.","commonSituations":"Scripts migrated from other SQL engines using unsupported EXPLAIN types, forked grammars with a new type added only to the .g4 file.","solutions":["Use one of the supported types: LOGICAL, DISTRIBUTED, VALIDATE, or IO.","Omit the TYPE clause to use the default.","In a fork, add a case for the new token plus a matching ExplainType.Type enum constant.","Regenerate the parser from the same SqlBase.g4 that AstBuilder was written against."],"exampleFix":"// before\nEXPLAIN (TYPE PHYSICAL) SELECT * FROM t;\n// after\nEXPLAIN (TYPE DISTRIBUTED) SELECT * FROM t;","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"LOGICAL\", \"DISTRIBUTED\", \"VALIDATE\", \"IO\");\nif (type != null && !allowed.contains(type.toUpperCase(Locale.ROOT))) {\n    throw new IllegalArgumentException(\"EXPLAIN TYPE must be LOGICAL, DISTRIBUTED, VALIDATE or IO\");\n}","typeGuard":"boolean isSupportedExplainType(String s) {\n    return s != null && Set.of(\"LOGICAL\", \"DISTRIBUTED\", \"VALIDATE\", \"IO\")\n        .contains(s.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"try {\n    parser.createStatement(sql);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported EXPLAIN type\")) {\n        sql = sql.replaceFirst(\"(?i)TYPE\\\\s+\\\\S+\", \"TYPE LOGICAL\");\n        parser.createStatement(sql);\n    } else throw e;\n}","preventionTips":["Restrict EXPLAIN (TYPE ...) values to the four supported ones in client code.","Test explain statements against the deployed Presto version.","Avoid translating EXPLAIN options verbatim from other engines."],"tags":["sql-parser","explain","illegal-argument"],"backgroundTag":"unsupported-enum-value","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"}