{"record":{"id":"74cfee3dad3923b9","repo":"prestodb/presto","slug":"unsupported-type-74cfee","errorCode":null,"errorMessage":"Unsupported Type: ","messagePattern":"Unsupported Type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java","lineNumber":2033,"sourceCode":"                new SubqueryExpression(getLocation(context.query()), (Query) visit(context.query())));\n    }\n\n    // ************** value expressions **************\n\n    @Override\n    public Node visitTableVersion(SqlBaseParser.TableVersionContext context)\n    {\n        Expression child = (Expression) visit(context.valueExpression());\n\n        switch (context.tableVersionType.getType()) {\n            case SqlBaseLexer.SYSTEM_TIME:\n            case SqlBaseLexer.TIMESTAMP:\n                return timestampExpression(getLocation(context), getTableVersionOperator((Token) context.tableVersionState().getChild(0).getPayload()), child);\n            case SqlBaseLexer.SYSTEM_VERSION:\n            case SqlBaseLexer.VERSION:\n                return versionExpression(getLocation(context), getTableVersionOperator((Token) context.tableVersionState().getChild(0).getPayload()), child);\n            default:\n                throw new UnsupportedOperationException(\"Unsupported Type: \" + context.tableVersionType.getText());\n        }\n    }\n\n    @Override\n    public Node visitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext context)\n    {\n        Expression child = (Expression) visit(context.valueExpression());\n\n        switch (context.operator.getType()) {\n            case SqlBaseLexer.MINUS:\n                return ArithmeticUnaryExpression.negative(getLocation(context), child);\n            case SqlBaseLexer.PLUS:\n                return ArithmeticUnaryExpression.positive(getLocation(context), child);\n            default:\n                throw new UnsupportedOperationException(\"Unsupported sign: \" + context.operator.getText());\n        }\n    }\n","sourceCodeStart":2015,"sourceCodeEnd":2051,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java#L2015-L2051","documentation":"AstBuilder.visitTableVersionState (table version / temporal query handling) throws this UnsupportedOperationException when the tableVersionType token is not TIMESTAMP, SYSTEM_VERSION, or VERSION. It means the version specifier in a FOR ... clause is a type the builder does not map.","triggerScenarios":"Parsing temporal syntax like 'SELECT ... FROM t FOR <type> <value>' where <type> is not TIMESTAMP, SYSTEM_VERSION or VERSION, e.g. fork-added version tokens not wired into the switch.","commonSituations":"Forked/patched grammars adding new temporal clause forms, or dialect-specific version keywords (e.g. 'AS OF') pasted into Presto SQL.","solutions":["Use FOR TIMESTAMP <expr>, FOR SYSTEM_VERSION AS OF ..., or FOR VERSION AS OF ... syntax.","Check the exact text of the version keyword for typos.","If the grammar defines extra version types, extend this switch to map them to versionExpression/timestampExpression.","Regenerate the parser so grammar and AstBuilder agree."],"exampleFix":"// before\nSELECT * FROM t FOR SNAPSHOT AS OF '2024-01-01';\n// after\nSELECT * FROM t FOR VERSION AS OF '2024-01-01';","handlingStrategy":"validation","validationCode":"// temporal clause must be TIMESTAMP, SYSTEM_VERSION or VERSION\nif (!Pattern.compile(\"(?i)FOR\\\\s+(TIMESTAMP|SYSTEM_VERSION|VERSION)\\\\b\").matcher(sql).find()\n        && Pattern.compile(\"(?i)\\\\bFOR\\\\s+\\\\w+\\\\s+(AS\\\\s+OF|\\\\S+)\").matcher(sql).find()) {\n    throw new IllegalArgumentException(\"Unsupported table version type\");\n}","typeGuard":"boolean isSupportedVersionType(String token) {\n    return token != null && Set.of(\"TIMESTAMP\", \"SYSTEM_VERSION\", \"VERSION\")\n        .contains(token.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"try {\n    parser.createStatement(sql);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Unsupported Type:\")) {\n        throw new IllegalArgumentException(\"Use FOR TIMESTAMP/FOR VERSION/FOR SYSTEM_VERSION clauses: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Use only the documented temporal syntax (FOR TIMESTAMP / FOR VERSION / FOR SYSTEM_VERSION AS OF ...).","Avoid pasting AS OF / SNAPSHOT dialect syntax from other engines.","Update the switch when adding temporal tokens to a forked grammar."],"tags":["sql-parser","temporal","unsupported-operation"],"backgroundTag":"unsupported-sql-syntax","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"}