apache/iceberg · error · UnsupportedOperationException
Wrong number of inputs (expected value)
Error message
Wrong number of inputs (expected value)
What it means
This error comes from the shared `UnaryUnboundFunction` helper used by Iceberg's unary Spark catalog functions (years/months/days/hours). It throws when `bind` is called with an input type whose field count is not exactly 1, guarding arity before extracting the single value type.
Source
Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/functions/UnaryUnboundFunction.java:39
import org.apache.spark.sql.connector.catalog.functions.BoundFunction;
import org.apache.spark.sql.connector.catalog.functions.UnboundFunction;
import org.apache.spark.sql.types.DataType;
import org.apache.spark.sql.types.StructType;
/** An unbound function that accepts only one argument */
abstract class UnaryUnboundFunction implements UnboundFunction {
@Override
public BoundFunction bind(StructType inputType) {
DataType valueType = valueType(inputType);
return doBind(valueType);
}
protected abstract BoundFunction doBind(DataType valueType);
private DataType valueType(StructType inputType) {
if (inputType.size() != 1) {
throw new UnsupportedOperationException("Wrong number of inputs (expected value)");
}
return inputType.fields()[0].dataType();
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Call the function with exactly one argument: `years(ts_col)`.
- Remove extra arguments or switch to a function that supports them.
- Confirm the expected signature with DESCRIBE FUNCTION.
Example fix
// before
spark.sql("SELECT years(ts_col, 'UTC') FROM t")
// after
spark.sql("SELECT years(ts_col) FROM t") Defensive patterns
Strategy: validation
Validate before calling
if (args.length != 1) throw new IllegalArgumentException("years/months/days/hours expect exactly 1 argument"); Try / catch
try { spark.sql("SELECT years(ts_col) FROM t"); } catch (Exception e) { if (e.getMessage().contains("Wrong number of inputs (expected value)")) { /* fix arity to 1 */ } throw e; } Prevention
- Call unary Iceberg functions with exactly one argument.
- Do not copy binary-function (truncate) call patterns to unary functions.
- Confirm signatures with DESCRIBE FUNCTION.
When it happens
Trigger: Calling a unary Iceberg function like `years(col)` with zero or multiple arguments, e.g. `years()` or `years(a, b)`.
Common situations: Copy-pasting binary function call patterns (like truncate) to unary functions; generated SQL emitting extra arguments; adding optional parameters the function does not support.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Wrong number of inputs (expected width and value)
- Expected truncation col to be tinyint, shortint, int, bigint
- Wrong number of inputs (expected numBuckets and value)
- Cannot bind: %s does not accept arguments
- Cannot bind: ${name()} does not accept arguments
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/ccdc2d7069a00056.
Report an issue: GitHub.