{"record":{"id":"dc812e18b56c5749","repo":"apache/iceberg","slug":"wrong-number-of-inputs-expected-value-dc812e","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.2/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.2/spark/src/main/java/org/apache/iceberg/spark/functions/UnaryUnboundFunction.java#L21-L45","documentation":"UnaryUnboundFunction is the base class for Iceberg's single-argument Spark transform functions (days, months, hours, years, etc.). Its valueType() checks that exactly one argument was supplied; if zero or multiple arguments are passed, binding fails with this UnsupportedOperationException. This is an argument-count (arity) error raised during query analysis before doBind type checks run.","triggerScenarios":"Calling a unary Iceberg transform with the wrong number of arguments, e.g. days() with no argument or days(a, b) with two; typo'd function names routing arguments to a unary function.","commonSituations":"Generated/templated SQL emitting empty argument lists; confusing Spark built-ins that take different arities with Iceberg transform functions; copy-paste errors adding extra arguments.","solutions":["Supply exactly one argument: days(ts_col).","Remove extra arguments if more than one was passed.","Verify the intended function — some Iceberg functions like bucket/truncate need two arguments, unary ones need one.","Run DESCRIBE FUNCTION <fn> to confirm the expected arity."],"exampleFix":"// before\nSELECT days(ts_col, 'UTC') FROM t\n// after\nSELECT days(ts_col) FROM t","handlingStrategy":"validation","validationCode":"// Spark Scala — for any unary Iceberg transform (days/months/hours/years)\nval args: Seq[Column] = Seq(col)\nrequire(args.size == 1, s\"unary transform requires exactly 1 argument, got ${args.size}\")","typeGuard":null,"tryCatchPattern":"try {\n  df.select(expr(\"days(ts_col)\"))\n} catch {\n  case e: UnsupportedOperationException if e.getMessage.contains(\"Wrong number of inputs (expected value)\") =>\n    throw new IllegalArgumentException(\"This Iceberg transform takes exactly one value argument\", e)\n}","preventionTips":["Confirm arity with DESCRIBE FUNCTION <name> before calling","Pass exactly one column/expression to days/months/hours/years","Fix SQL generators that emit empty or multi-value argument lists","Remember only bucket() and truncate() take two arguments among Iceberg transforms"],"tags":["spark","sql-function","arity","argument-count"],"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"}