{"record":{"id":"4542d85f325b7589","repo":"apache/iceberg","slug":"wrong-number-of-inputs-expected-value-4542d8","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/v4.0/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/v4.0/spark/src/main/java/org/apache/iceberg/spark/functions/UnaryUnboundFunction.java#L21-L45","documentation":"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.","triggerScenarios":"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.","commonSituations":"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().","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."],"exampleFix":"// before\nSELECT iceberg.days(a, b) FROM t;\n// after\nSELECT iceberg.days(a), iceberg.days(b) FROM t;","handlingStrategy":"validation","validationCode":"-- unary functions take exactly 1 argument\nSELECT iceberg.days(col) FROM t;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["spark","sql-function-binding","argument-count"],"backgroundTag":"invalid-argument-count","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}