prestodb/presto · error · PrestoException
INVALID_FUNCTION_ARGUMENT
INVALID_FUNCTION_ARGUMENT
Error message
There must be two or more arguments to array_concat
What it means
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.)
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayConcatFunction.java:104
}
@Override
public String getDescription()
{
return DESCRIPTION;
}
@Override
public ComplexTypeFunctionDescriptor getComplexTypeFunctionDescriptor()
{
return descriptor;
}
@Override
public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager)
{
if (arity < 2) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "There must be two or more arguments to " + FUNCTION_NAME);
}
Type elementType = boundVariables.getTypeVariable("E");
VarArgsToArrayAdapterGenerator.VarArgMethodHandle varArgMethodHandle = generateVarArgsToArrayAdapter(
Block.class,
Block.class,
arity,
METHOD_HANDLE.bindTo(elementType));
return new BuiltInScalarFunctionImplementation(
false,
nCopies(arity, valueTypeArgumentProperty(RETURN_NULL_ON_NULL)),
varArgMethodHandle.getMethodHandle());
}
@UsedByGeneratedCode
public static Block concat(Type elementType, Block[] blocks)View on GitHub (pinned to 55bb57d202)
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]).
Example fix
// before array_concat(single_array) // after single_array -- or array_concat(a, b) with a real second operand
Defensive patterns
Strategy: validation
Validate before calling
// in SQL-building code if (operands.length < 2) return operands[0]; // skip array_concat
Prevention
- Only emit array_concat with >= 2 operands
- Handle the single-array case by identity
- Review generated-SQL tests for empty operand lists
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- NOT_SUPPORTED
- Type must be an ArrayType for ListVector
- Type must be an ArrayType for FixedSizeListVector
- ELASTICSEARCH_TYPE_MISMATCH
- createArrayOf
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5fbbcb8b2086497d.
Report an issue: GitHub.