{"record":{"id":"b8c280eca0d36b22","repo":"prestodb/presto","slug":"argument-of-type-s-from-s-is-not-supported","errorCode":null,"errorMessage":"Argument of type %s from %s is not supported.","messagePattern":"Argument of type (.+?) 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":478,"sourceCode":"\n        if (expression instanceof FunctionCall) {\n            FunctionCall functionCall = (FunctionCall) expression;\n\n            Stream<Expression> arguments = functionCall.getArguments().stream();\n            arguments = Stream.concat(arguments, functionCall.getOrderBy().map(OrderBy::getSortItems).orElse(ImmutableList.of()).stream().map(SortItem::getSortKey));\n            arguments = Stream.concat(arguments, functionCall.getWindow().map(Window::getPartitionBy).orElse(ImmutableList.of()).stream());\n            arguments = Stream.concat(arguments, functionCall.getWindow().flatMap(Window::getOrderBy).map(OrderBy::getSortItems).orElse(ImmutableList.of()).stream().map(SortItem::getSortKey));\n\n            arguments.forEach(argument -> {\n                if (argument instanceof Identifier || argument instanceof Literal) {\n                    return;\n                }\n                if (argument instanceof ArrayConstructor) {\n                    if (((ArrayConstructor) argument).getValues().stream().allMatch(Literal.class::isInstance)) {\n                        return;\n                    }\n                }\n                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()));","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java#L460-L496","documentation":"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.","triggerScenarios":"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])'.","commonSituations":"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.","solutions":["Change the spec so all arguments are literals, e.g. 'myfunc(1, ARRAY[1, 2])'","Ensure array arguments only contain literal values (no column refs or nested calls inside the ARRAY constructor)","Substitute the enclosing function at a level where arguments are constant"],"exampleFix":"// before\noriginalSpec = \"myfunc(x)\"\n// after\noriginalSpec = \"myfunc(1)\"","handlingStrategy":"validation","validationCode":"FunctionCall fc = (FunctionCall) parsed;\nboolean allConst = fc.getArguments().stream().allMatch(a ->\n    a instanceof Literal ||\n    (a instanceof ArrayConstructor && ((ArrayConstructor) a).getValues().stream().allMatch(Literal.class::isInstance)));","typeGuard":"boolean hasConstantArgsOnly(FunctionCall fc) {\n    return fc.getArguments().stream().allMatch(a ->\n        a instanceof Literal ||\n        (a instanceof ArrayConstructor && ((ArrayConstructor) a).getValues().stream().allMatch(Literal.class::isInstance)));\n}","tryCatchPattern":"try {\n    rewriter = FunctionCallRewriter.getInstance(functionCallSubstitutes, typeManager);\n} catch (IllegalArgumentException e) {\n    LOG.error(\"Original function args must be literals: %s\", e.getMessage());\n    rewriter = Optional.empty();\n}","preventionTips":["Configure substitutions only for constant-argument (fully-qualified) overloads","Inline column values as literals in the spec","Avoid nested calls or identifiers inside ARRAY[...] in specs"],"tags":["unsupported","arguments","validation","verifier"],"backgroundTag":"unsupported-argument-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"}