{"record":{"id":"09b04261aab4b43d","repo":"prestodb/presto","slug":"substitution-of-with-from-s-is-not-supported","errorCode":null,"errorMessage":"Substitution of with from %s is not supported.","messagePattern":"Substitution of with from (.+?) is not supported\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java","lineNumber":496,"sourceCode":"                throw new IllegalArgumentException(String.format(\"Argument of type %s from %s is not supported.\", argument.getClass().getSimpleName(), functionCallSpec));\n            });\n        }\n        return expression;\n    }\n\n    private static Expression parseSubstituteExpression(String expressionSpec)\n    {\n        SqlParser sqlParser = new SqlParser();\n        Expression expression;\n        try {\n            expression = sqlParser.createExpression(expressionSpec, PARSING_OPTIONS);\n        }\n        catch (ParsingException e) {\n            throw new IllegalArgumentException(String.format(\"Expression spec %s is not in a valid format.\", expressionSpec), e);\n        }\n\n        if (SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().noneMatch(clazz -> clazz.isAssignableFrom(expression.getClass()))) {\n            throw new IllegalArgumentException(String.format(\"Substitution of with from %s is not supported.\", expression.getClass().getSimpleName()));\n        }\n\n        return expression;\n    }\n\n    private static Identifier toIdentifier(Expression expression)\n    {\n        if (expression instanceof Identifier) {\n            return (Identifier) expression;\n        }\n        return new Identifier(String.valueOf(expression.toString().hashCode()));\n    }\n}\n","sourceCodeStart":478,"sourceCodeEnd":510,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java#L478-L510","documentation":"FunctionCallRewriter validates that the parsed expression spec produces an Expression type it knows how to substitute. If the parsed expression's class is not assignable from any entry in SUPPORTED_SUBSTITUTE_EXPRESSIONS, it throws this IllegalArgumentException, indicating the verifier cannot safely rewrite this function-call expression form.","triggerScenarios":"Calling parseExpression / rewriteQuerySupport with an expressionSpec string that parses successfully into an unsupported Expression subclass (e.g. arithmetic expressions, lambdas, or other node types outside the supported set such as FunctionCall/Identifier).","commonSituations":"Users add a verifier SQL query whose rewritten expression contains syntax outside the supported substitute set; a query upgrade or new SQL feature introduces expression types the rewriter was never taught to handle; a typo makes a spec parse into the wrong Expression kind.","solutions":["Check the expressionSpec string; simplify it to a function call or other expression type listed in SUPPORTED_SUBSTITUTE_EXPRESSIONS","Add the required Expression subclass to SUPPORTED_SUBSTITUTE_EXPRESSIONS and ensure the rewriter handles it","Update the verifier query configuration to avoid the unsupported expression form","If a new SQL feature is involved, extend FunctionCallRewriter with a rewrite branch for the new expression type"],"exampleFix":"// before\nString spec = \"1 + 2\"; // parses to ArithmeticExpression -> unsupported\n// after\nString spec = \"abs(-1)\"; // parses to FunctionCall -> supported","handlingStrategy":"validation","validationCode":"Class<?> exprClass = FunctionCallRewriter.parseExpression(spec).getClass();\nboolean supported = FunctionCallRewriter.SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().anyMatch(c -> c.isAssignableFrom(exprClass));\nif (!supported) throw new IllegalArgumentException(\"Spec produces unsupported expression type: \" + exprClass.getSimpleName());","typeGuard":"boolean isSupportedExpression(Expression e) {\n    return FunctionCallRewriter.SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().anyMatch(c -> c.isAssignableFrom(e.getClass()));\n}","tryCatchPattern":"try {\n    Expression e = FunctionCallRewriter.parseExpression(spec);\n} catch (IllegalArgumentException ex) {\n    log.warn(\"Expression spec rejected: %s\", ex.getMessage()); // skip or fall back to unrewritten query\n}","preventionTips":["Keep expressionSpecs limited to function calls and identifiers the rewriter documents as supported","Unit-test every expression spec in verifier configs against the rewriter before deployment","When adding new SQL syntax, update SUPPORTED_SUBSTITUTE_EXPRESSIONS in the same change"],"tags":["verifier","expression-rewrite","unsupported-type","illegal-argument"],"backgroundTag":"unsupported-expression-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"}