apache/iceberg · error · UnsupportedOperationException
Wrong number of inputs (expected value)
Error message
Wrong number of inputs (expected value)
What it means
UnaryUnboundFunction is the shared base for single-argument Iceberg functions (days, hours, months, years). Before dispatching to doBind, its private valueType() checks that exactly one input was given and throws UnsupportedOperationException for any other argument count.
Solutions
- Pass exactly one column: iceberg.days(col).
- For multiple columns, apply the transform per column: days(a) and days(b) separately.
- Inspect generated SQL to restore the missing argument.
Example fix
// before SELECT iceberg.days(a, b) FROM t; // after SELECT iceberg.days(a), iceberg.days(b) FROM t;
Defensive patterns
Strategy: validation
Validate before calling
-- unary functions take exactly 1 argument SELECT iceberg.days(col) FROM t;
Prevention
- Apply unary transforms per column rather than passing multiple columns in one call
- In code generators, enforce argument-count checks matching each function's arity
When it happens
Trigger: Calling iceberg.days() with zero arguments, or iceberg.months(col1, col2) with two or more — e.g. days() from templated SQL missing its parameter, or days(a, b) trying to bucket on two columns.
Common situations: Templated/generators omitting the argument; attempting multi-column transforms in one call (Iceberg requires one transform per column); copy-paste from binary functions like truncate().
Related errors
- Cannot bind: does not accept arguments
- Wrong number of inputs (expected width and value)
- Cannot bind: does not accept arguments
- Expected column to be date, tinyint, smallint, int, bigint…
- Expected number of buckets to be tinyint, shortint or int
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/4542d85f325b7589.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.0/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)