{"record":{"id":"c60a120e9a128be0","repo":"prestodb/presto","slug":"not-yet-implemented-getclass-getsimplename","errorCode":null,"errorMessage":"Not yet implemented: \" + getClass().getSimpleName() + \" for \" + node.getClass().getName()","messagePattern":"Not yet implemented: \" \\+ getClass\\(\\)\\.getSimpleName\\(\\) \\+ \" for \" \\+ node\\.getClass\\(\\)\\.getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/DefaultTreeRewriter.java","lineNumber":101,"sourceCode":"\n/**\n * A default implementation of {@link AstVisitor} that reconstructs a node if any of its children is reconstructed.\n * Expression node reconstruction is not supported and left to the users. At the moment it is only used for presto.verifier package.\n * Generalize it with caution.\n */\npublic class DefaultTreeRewriter<C>\n        extends AstVisitor<Node, C>\n{\n    @Override\n    protected Node visitNode(Node node, C context)\n    {\n        return node;\n    }\n\n    @Override\n    protected Node visitExpression(Expression node, C context)\n    {\n        throw new UnsupportedOperationException(\"Not yet implemented: \" + getClass().getSimpleName() + \" for \" + node.getClass().getName());\n    }\n\n    @Override\n    protected Node visitAddColumn(AddColumn node, C context)\n    {\n        Node column = process(node.getColumn(), context);\n        Optional<ColumnPosition> position = processColumnPosition(node.getPosition(), context);\n        if (node.getColumn() == column && sameElement(node.getPosition(), position)) {\n            return node;\n        }\n\n        return new AddColumn(node.getName(), (ColumnDefinition) column, position, node.isTableExists(), node.isColumnNotExists());\n    }\n\n    @Override\n    protected Node visitAliasedRelation(AliasedRelation node, C context)\n    {\n        Node relation = process(node.getRelation(), context);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/DefaultTreeRewriter.java#L83-L119","documentation":"DefaultTreeRewriter extends AstVisitor and overrides only the expression node types it can rewrite; visitExpression is the fallback for any unhandled Expression. Hitting it means the rewriter encountered an expression type (e.g. SubscriptExpression, LambdaExpression, BindExpression, functional calls) it does not know how to rewrite, and it aborts with UnsupportedOperationException naming both the rewriter class and the node class.","triggerScenarios":"Calling rewrite(...) with a SELECT query containing an expression not covered by the overridden visitXxx methods (e.g. lambda/higher-order function expressions, SubscriptExpression, Format/JsonFunction expressions in verifier test queries).","commonSituations":"Running the verifier on suites using newer SQL syntax (lambdas, subscript/JSON functions) that predates the added expression types; verifying queries from other engines' dialects containing exotic expressions; adding new Presto expressions without updating DefaultTreeRewriter.","solutions":["Identify the node class named in the exception message and check which SQL construct it corresponds to.","Add an override in DefaultTreeRewriter (or a subclass) for that node type that rewrites or passes through the node.","As an interim workaround, exclude queries using that expression from the verifier suite.","Prefer a generic pass-through (return node) for expression types that need no rewriting."],"exampleFix":"// before\n@Override\nprotected Node visitExpression(Expression node, C context) {\n    throw new UnsupportedOperationException(\"Not yet implemented: \" + getClass().getSimpleName() + \" for \" + node.getClass().getName());\n}\n// after\n@Override\nprotected Node visitSubscriptExpression(SubscriptExpression node, C context) {\n    return new SubscriptExpression(process(node.getBase(), context), process(node.getIndex(), context));\n}","handlingStrategy":"try-catch","validationCode":"// Java: pre-scan query AST for expression types the rewriter lacks handlers for\nSet<Class<? extends Expression>> unsupported = ImmutableSet.of(LambdaExpression.class, BindExpression.class, SubscriptExpression.class);\nfor (Expression e : ExpressionTreeBuilder.collectExpressions(parsedBody)) {\n    if (unsupported.contains(e.getClass())) {\n        throw new IllegalArgumentException(\"Query uses unsupported expression: \" + e.getClass().getSimpleName());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    rewritten = treeRewriter.rewrite(expression, blacklist);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Not yet implemented\")) {\n        report.skip(query, \"Rewriter cannot handle: \" + e.getMessage());\n        return;\n    }\n    throw e;\n}","preventionTips":["Avoid verifier suites using lambdas/higher-order or exotic expressions.","Add a pass-through override for expression types needing no rewriting.","Update DefaultTreeRewriter when new Presto expression types are introduced.","Test the rewriter against all expressions used in your suites."],"tags":["verifier","ast","unsupported","rewrite"],"backgroundTag":"unhandled-ast-node","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"}