{"record":{"id":"44833c62097d5144","repo":"prestodb/presto","slug":"expression-spec-s-is-not-in-a-valid-format","errorCode":null,"errorMessage":"Expression spec %s is not in a valid format.","messagePattern":"Expression 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":492,"sourceCode":"                    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()));\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":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/FunctionCallRewriter.java#L474-L510","documentation":"parseSubstituteExpression parses the replacement spec with SqlParser.createExpression; a ParsingException is wrapped into this IllegalArgumentException. The substitute side of a function-call-substitutes entry must be a syntactically valid SQL expression.","triggerScenarios":"Passing a substitute expression spec that fails parsing, e.g. 'abs(' or 'if(x' in the second half of a function-call-substitutes entry.","commonSituations":"Truncated or typoed replacement expressions; properties-file escaping issues (e.g. backslashes or quotes in CASE/IF expressions); writing invalid SQL like a bare comma-separated list.","solutions":["Fix the substitute spec so it parses as a single SQL expression, e.g. 'abs(x)' or 'CASE WHEN x > 0 THEN 1 ELSE 0 END'","Validate by running `new SqlParser().createExpression(spec, PARSING_OPTIONS)` against the spec before putting it in config","Check properties-file quoting/escaping for special characters in the expression"],"exampleFix":"// before\nsubstituteSpec = \"abs(\"\n// after\nsubstituteSpec = \"abs(x)\"","handlingStrategy":"validation","validationCode":"try {\n    new SqlParser().createExpression(substituteSpec, PARSING_OPTIONS);\n} catch (ParsingException e) {\n    throw new IllegalArgumentException(\"Substitute spec does not parse: \" + substituteSpec, 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 substitute expression: %s\", e.getMessage());\n    }\n}","preventionTips":["Validate substitute expressions with SqlParser before adding to config","Escape CASE/IF/ARRAY expressions correctly in properties files","Keep each substitute a single well-formed expression"],"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"}