apache/iceberg · error · UnsupportedOperationException
Wrong number of inputs (expected value)
Error message
Wrong number of inputs (expected value)
What it means
UnaryUnboundFunction is the base class for Iceberg Spark functions that take exactly one argument (e.g. years, months, days, bucket-less unary transforms). Its private valueType() throws this UnsupportedOperationException when the input StructType does not have exactly one field.
Source
Thrown at spark/v4.1/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, e.g. days(event_ts)
- If you intended a two-argument function (like date_add), use the correct Spark function instead
- Run DESCRIBE FUNCTION <name> to confirm the signature
Example fix
// before
SELECT years('2023-01-01', '2024-01-01');
// after
SELECT years(TIMESTAMP '2023-01-01 00:00:00'); Defensive patterns
Strategy: validation
Validate before calling
if (args.length != 1) throw new IllegalArgumentException(s"$fnName expects exactly one argument")
Try / catch
try { ... } catch { case e: UnsupportedOperationException if e.getMessage.contains("Wrong number of inputs") => ... } Prevention
- Iceberg transform functions years/months/days/hours are unary — pass one value
- Compare against Spark built-ins with different arities
- Unit-test generated SQL for these calls
When it happens
Trigger: Calling a unary Iceberg function like years('2023-01-01') with zero arguments, or with two or more arguments.
Common situations: Confusing Iceberg's partition-transform functions (years/months/days/hours take one value) with multi-arg date functions; SQL templating bugs that duplicate or drop an argument.
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 width to be tinyint, shortint or int
- Expected truncation col to be tinyint, shortint, int, bigint
- Expected value to be date or timestamp:
- Cannot convert type to SQL: %s
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/c873d2dab251dd2e.
Report an issue: GitHub.