{"record":{"id":"5fbbcb8b2086497d","repo":"prestodb/presto","slug":"invalid-function-argument-5fbbcb","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"There must be two or more arguments to array_concat","messagePattern":"There must be two or more arguments to array_concat","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayConcatFunction.java","lineNumber":104,"sourceCode":"    }\n\n    @Override\n    public String getDescription()\n    {\n        return DESCRIPTION;\n    }\n\n    @Override\n    public ComplexTypeFunctionDescriptor getComplexTypeFunctionDescriptor()\n    {\n        return descriptor;\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 arguments to \" + FUNCTION_NAME);\n        }\n\n        Type elementType = boundVariables.getTypeVariable(\"E\");\n\n        VarArgsToArrayAdapterGenerator.VarArgMethodHandle varArgMethodHandle = generateVarArgsToArrayAdapter(\n                Block.class,\n                Block.class,\n                arity,\n                METHOD_HANDLE.bindTo(elementType));\n\n        return new BuiltInScalarFunctionImplementation(\n                false,\n                nCopies(arity, valueTypeArgumentProperty(RETURN_NULL_ON_NULL)),\n                varArgMethodHandle.getMethodHandle());\n    }\n\n    @UsedByGeneratedCode\n    public static Block concat(Type elementType, Block[] blocks)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayConcatFunction.java#L86-L122","documentation":"array_concat is a variadic function; its specialize() checks the bound arity and requires at least 2 arguments. Fewer than two array arguments cannot be dispatched to the generated varargs adapter, so binding fails with INVALID_FUNCTION_ARGUMENT. (Single-array concat should use the dedicated single-argument overload if available.)","triggerScenarios":"Planning a call to the generic variadic array_concat with arity 0 or 1 — typically from generated SQL, a prepared statement built dynamically, or misrouting to the wrong function signature.","commonSituations":"Code generators or ORMs that emit array_concat(a) for a single array; users writing array_concat() expecting identity behavior; concatenating one array after filtering other operands away.","solutions":["Pass at least two array arguments; for a single array just return it directly.","Use the dedicated one-argument array_concat overload / array_flatten instead of the variadic one.","Fix the SQL-building code to omit array_concat entirely when fewer than two operands.","Concatenate with a no-op second argument only as a last resort: array_concat(a, a[1..0])."],"exampleFix":"// before\narray_concat(single_array)\n// after\nsingle_array  -- or array_concat(a, b) with a real second operand","handlingStrategy":"validation","validationCode":"// in SQL-building code\nif (operands.length < 2) return operands[0]; // skip array_concat","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only emit array_concat with >= 2 operands","Handle the single-array case by identity","Review generated-SQL tests for empty operand lists"],"tags":["array","sql-planning","arity"],"backgroundTag":"wrong-number-of-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"}