prestodb/presto · error · IllegalArgumentException
Substitution of with from
Error message
Substitution of with from %s is not supported.
What it means
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.
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
Example fix
// before String spec = "1 + 2"; // parses to ArithmeticExpression -> unsupported // after String spec = "abs(-1)"; // parses to FunctionCall -> supported
Defensive patterns
Strategy: validation
Validate before calling
Class<?> exprClass = FunctionCallRewriter.parseExpression(spec).getClass();
boolean supported = FunctionCallRewriter.SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().anyMatch(c -> c.isAssignableFrom(exprClass));
if (!supported) throw new IllegalArgumentException("Spec produces unsupported expression type: " + exprClass.getSimpleName()); Type guard
boolean isSupportedExpression(Expression e) {
return FunctionCallRewriter.SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().anyMatch(c -> c.isAssignableFrom(e.getClass()));
} Try / catch
try {
Expression e = FunctionCallRewriter.parseExpression(spec);
} catch (IllegalArgumentException ex) {
log.warn("Expression spec rejected: %s", ex.getMessage()); // skip or fall back to unrewritten query
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Original function call and substitute must both be specified
- Unsupported FieldVector type
- Unsupported table properties value
- A null map must have zero entries
- Access control ' ' is already registered
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/09b04261aab4b43d.
Report an issue: GitHub.
Appendix: source
Thrown at presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java:496
throw new IllegalArgumentException(String.format("Argument of type %s from %s is not supported.", argument.getClass().getSimpleName(), functionCallSpec));
});
}
return expression;
}
private static Expression parseSubstituteExpression(String expressionSpec)
{
SqlParser sqlParser = new SqlParser();
Expression expression;
try {
expression = sqlParser.createExpression(expressionSpec, PARSING_OPTIONS);
}
catch (ParsingException e) {
throw new IllegalArgumentException(String.format("Expression spec %s is not in a valid format.", expressionSpec), e);
}
if (SUPPORTED_SUBSTITUTE_EXPRESSIONS.stream().noneMatch(clazz -> clazz.isAssignableFrom(expression.getClass()))) {
throw new IllegalArgumentException(String.format("Substitution of with from %s is not supported.", expression.getClass().getSimpleName()));
}
return expression;
}
private static Identifier toIdentifier(Expression expression)
{
if (expression instanceof Identifier) {
return (Identifier) expression;
}
return new Identifier(String.valueOf(expression.toString().hashCode()));
}
}
View on GitHub (pinned to 55bb57d202)