{"record":{"id":"d2bcd50db7fc2013","repo":"prestodb/presto","slug":"invalid-function-argument-d2bcd5","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"There must be two or more concatenation arguments","messagePattern":"There must be two or more concatenation arguments","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ConcatFunction.java","lineNumber":111,"sourceCode":"    }\n\n    @Override\n    public boolean isDeterministic()\n    {\n        return true;\n    }\n\n    @Override\n    public String getDescription()\n    {\n        return description;\n    }\n\n    @Override\n    public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager)\n    {\n        if (arity < 2) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"There must be two or more concatenation arguments\");\n        }\n\n        Class<?> clazz = generateConcat(getSignature().getReturnType(), arity);\n        MethodHandle methodHandle = methodHandle(clazz, \"concat\", nCopies(arity, Slice.class).toArray(new Class<?>[arity]));\n\n        return new BuiltInScalarFunctionImplementation(\n                false,\n                nCopies(arity, valueTypeArgumentProperty(RETURN_NULL_ON_NULL)),\n                methodHandle);\n    }\n\n    @UsedByGeneratedCode\n    public static Slice concat(Slice... slices)\n    {\n        int i;\n        for (i = 0; i < slices.length; i++) {\n            if (slices[i].length() > 0) {\n                break;","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ConcatFunction.java#L93-L129","documentation":"The variadic concat implementation is generated for a fixed arity at specialization time; it requires at least two arguments. Calling the concat signature with fewer than two arguments is rejected with INVALID_FUNCTION_ARGUMENT during function specialization.","triggerScenarios":"Invoking CONCAT with a single argument (or zero) via a dynamically-bound call path that bypasses the normal overload resolution, e.g. CONCAT(x) where a dialect allows one-arg concat.","commonSituations":"Queries generated by ORMs/tools that emit CONCAT(single_expr); migrating from engines that accept one-argument CONCAT; dynamic SQL built with conditional argument lists that collapsed to one item.","solutions":["Ensure at least two arguments: CONCAT(a, '') if a single value is all you have","Use CAST(x AS VARCHAR) alone instead of CONCAT for stringifying a single value","Fix the SQL generator to skip CONCAT when only one argument survives"],"exampleFix":"// before\nSELECT CONCAT(name) FROM t;\n// after\nSELECT CAST(name AS VARCHAR) FROM t;","handlingStrategy":"validation","validationCode":"if (args.length < 2) throw new IllegalArgumentException(\"need >=2 concat args\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit CONCAT only with two or more arguments"],"tags":["sql","scalar-function","invalid-argument","string-concat"],"backgroundTag":"insufficient-function-arguments","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"}