{"record":{"id":"f67ca9329b5f5089","repo":"prestodb/presto","slug":"function-call-spec-s-is-not-in-a-valid-format","errorCode":null,"errorMessage":"Function call spec %s is not in a valid format.","messagePattern":"Function call spec (.+?) is not in a valid format\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java","lineNumber":454,"sourceCode":"                if (signature.getNameSuffix().equals(functionCall.getName().getSuffix())) {\n                    if (signature.getKind().equals(FunctionKind.AGGREGATE) || signature.getKind().equals(FunctionKind.WINDOW)) {\n                        return true;\n                    }\n                }\n            }\n            return false;\n        }\n    }\n\n    private static Expression parseOriginalFunctionCall(String functionCallSpec)\n    {\n        SqlParser sqlParser = new SqlParser();\n        Expression expression;\n        try {\n            expression = sqlParser.createExpression(functionCallSpec, PARSING_OPTIONS);\n        }\n        catch (ParsingException e) {\n            throw new IllegalArgumentException(String.format(\"Function call spec %s is not in a valid format.\", functionCallSpec), e);\n        }\n\n        if (SUPPORTED_ORIGINAL_FUNCTIONS.stream().noneMatch(clazz -> clazz.equals(expression.getClass()))) {\n            throw new IllegalArgumentException(String.format(\"Substituting %s in %s is not supported.\", expression.getClass().getSimpleName(), functionCallSpec));\n        }\n\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                }","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java#L436-L472","documentation":"FunctionCallRewriter parses each original function call spec with SqlParser.createExpression. If the spec is not syntactically valid SQL expression syntax, the ParsingException is wrapped into this IllegalArgumentException. The spec must parse to an expression before support checks run.","triggerScenarios":"Calling FunctionCallRewriter.getInstance (or parseOriginalFunctionCall via validateAndConstructFunctionCallSubstituteMap) with an original-function spec that fails SqlParser parsing under PARSING_OPTIONS, e.g. mismatched parentheses, invalid tokens, or reserved-word misuse like 'myfunc(1,' or 'function x'.","commonSituations":"Typos in the verifier configuration; quoting errors in properties files stripping parentheses; writing a full statement or type name instead of an expression; trailing commas in argument lists.","solutions":["Correct the spec so it is a syntactically valid SQL expression, e.g. 'myfunc(1, 2)'","Test the spec by parsing it with `new SqlParser().createExpression(spec, PARSING_OPTIONS)` locally before deploying the config","Check the properties file for characters (quotes, backslashes, trailing commas) mangled by properties-file parsing"],"exampleFix":"// before\noriginalSpec = \"sum(x,\"\n// after\noriginalSpec = \"sum(x)\"","handlingStrategy":"validation","validationCode":"// Pre-validate spec parses as an expression\ntry {\n    new SqlParser().createExpression(spec, PARSING_OPTIONS);\n} catch (ParsingException e) {\n    throw new IllegalArgumentException(\"Spec does not parse: \" + spec, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    rewriter = FunctionCallRewriter.getInstance(functionCallSubstitutes, typeManager);\n} catch (IllegalArgumentException e) {\n    if (e.getCause() instanceof ParsingException) {\n        LOG.error(\"Invalid SQL expression spec: %s\", e.getMessage());\n    }\n}","preventionTips":["Test every spec in a SQL client before adding it to config","Beware properties-file stripping of quotes and backslashes","Keep specs simple single expressions, not statements"],"tags":["sql-parser","parsing","validation","verifier"],"backgroundTag":"sql-parse-error","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"}