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

  1. Pass at least two array arguments; for a single array just return it directly.
  2. Use the dedicated one-argument array_concat overload / array_flatten instead of the variadic one.
  3. Fix the SQL-building code to omit array_concat entirely when fewer than two operands.
  4. 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

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


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/5fbbcb8b2086497d. Report an issue: GitHub.