prestodb/presto · error · IllegalArgumentException

Argument of type %s from %s is not supported.

Error message

Argument of type %s from %s is not supported.

What it means

For FunctionCall originals, every argument must be either a Literal or an ArrayConstructor whose values are all Literals. Arguments of any other expression type (identifiers, nested calls, arithmetic) are rejected with this IllegalArgumentException, since the rewriter matches on fully-qualified, constant-argument function signatures.

Source

Thrown at presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java:478

        if (expression instanceof FunctionCall) {
            FunctionCall functionCall = (FunctionCall) expression;

            Stream<Expression> arguments = functionCall.getArguments().stream();
            arguments = Stream.concat(arguments, functionCall.getOrderBy().map(OrderBy::getSortItems).orElse(ImmutableList.of()).stream().map(SortItem::getSortKey));
            arguments = Stream.concat(arguments, functionCall.getWindow().map(Window::getPartitionBy).orElse(ImmutableList.of()).stream());
            arguments = Stream.concat(arguments, functionCall.getWindow().flatMap(Window::getOrderBy).map(OrderBy::getSortItems).orElse(ImmutableList.of()).stream().map(SortItem::getSortKey));

            arguments.forEach(argument -> {
                if (argument instanceof Identifier || argument instanceof Literal) {
                    return;
                }
                if (argument instanceof ArrayConstructor) {
                    if (((ArrayConstructor) argument).getValues().stream().allMatch(Literal.class::isInstance)) {
                        return;
                    }
                }
                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()));

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Change the spec so all arguments are literals, e.g. 'myfunc(1, ARRAY[1, 2])'
  2. Ensure array arguments only contain literal values (no column refs or nested calls inside the ARRAY constructor)
  3. Substitute the enclosing function at a level where arguments are constant

Example fix

// before
originalSpec = "myfunc(x)"
// after
originalSpec = "myfunc(1)"
Defensive patterns

Strategy: validation

Validate before calling

FunctionCall fc = (FunctionCall) parsed;
boolean allConst = fc.getArguments().stream().allMatch(a ->
    a instanceof Literal ||
    (a instanceof ArrayConstructor && ((ArrayConstructor) a).getValues().stream().allMatch(Literal.class::isInstance)));

Type guard

boolean hasConstantArgsOnly(FunctionCall fc) {
    return fc.getArguments().stream().allMatch(a ->
        a instanceof Literal ||
        (a instanceof ArrayConstructor && ((ArrayConstructor) a).getValues().stream().allMatch(Literal.class::isInstance)));
}

Try / catch

try {
    rewriter = FunctionCallRewriter.getInstance(functionCallSubstitutes, typeManager);
} catch (IllegalArgumentException e) {
    LOG.error("Original function args must be literals: %s", e.getMessage());
    rewriter = Optional.empty();
}

Prevention

When it happens

Trigger: An original function-call spec like 'myfunc(a)' or 'myfunc(x + 1)' where any argument is a non-literal expression instead of a constant such as 'myfunc(1)' or 'myfunc(ARRAY[1, 2])'.

Common situations: Configuring substitution for calls with column arguments when the rewriter expects constant-argument overloads; dynamic arguments that should be resolved to literals first; copy-pasting a query call with column references.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/b8c280eca0d36b22. Report an issue: GitHub.