{"record":{"id":"ccdc2d7069a00056","repo":"apache/iceberg","slug":"wrong-number-of-inputs-expected-value","errorCode":null,"errorMessage":"Wrong number of inputs (expected value)","messagePattern":"Wrong number of inputs \\(expected value\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/functions/UnaryUnboundFunction.java","lineNumber":39,"sourceCode":"import org.apache.spark.sql.connector.catalog.functions.BoundFunction;\nimport org.apache.spark.sql.connector.catalog.functions.UnboundFunction;\nimport org.apache.spark.sql.types.DataType;\nimport org.apache.spark.sql.types.StructType;\n\n/** An unbound function that accepts only one argument */\nabstract class UnaryUnboundFunction implements UnboundFunction {\n\n  @Override\n  public BoundFunction bind(StructType inputType) {\n    DataType valueType = valueType(inputType);\n    return doBind(valueType);\n  }\n\n  protected abstract BoundFunction doBind(DataType valueType);\n\n  private DataType valueType(StructType inputType) {\n    if (inputType.size() != 1) {\n      throw new UnsupportedOperationException(\"Wrong number of inputs (expected value)\");\n    }\n\n    return inputType.fields()[0].dataType();\n  }\n}\n","sourceCodeStart":21,"sourceCodeEnd":45,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/functions/UnaryUnboundFunction.java#L21-L45","documentation":"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.","triggerScenarios":"Calling a unary Iceberg function like `years(col)` with zero or multiple arguments, e.g. `years()` or `years(a, b)`.","commonSituations":"Copy-pasting binary function call patterns (like truncate) to unary functions; generated SQL emitting extra arguments; adding optional parameters the function does not support.","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."],"exampleFix":"// before\nspark.sql(\"SELECT years(ts_col, 'UTC') FROM t\")\n// after\nspark.sql(\"SELECT years(ts_col) FROM t\")","handlingStrategy":"validation","validationCode":"if (args.length != 1) throw new IllegalArgumentException(\"years/months/days/hours expect exactly 1 argument\");","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Call unary Iceberg functions with exactly one argument.","Do not copy binary-function (truncate) call patterns to unary functions.","Confirm signatures with DESCRIBE FUNCTION."],"tags":["spark","sql-function","arity","unsupported-operation"],"backgroundTag":"missing-required-argument","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}