{"record":{"id":"ac7f4ff87dfbcdea","repo":"apache/iceberg","slug":"cannot-bind-s-does-not-accept-arguments","errorCode":null,"errorMessage":"Cannot bind: %s does not accept arguments","messagePattern":"Cannot bind: (.+?) does not accept arguments","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/functions/IcebergVersionFunction.java","lineNumber":38,"sourceCode":"\nimport org.apache.iceberg.IcebergBuild;\nimport org.apache.spark.sql.catalyst.InternalRow;\nimport 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.DataTypes;\nimport org.apache.spark.sql.types.StructType;\nimport org.apache.spark.unsafe.types.UTF8String;\n\n/**\n * A function for use in SQL that returns the current Iceberg version, e.g. {@code SELECT\n * system.iceberg_version()} will return a String such as \"0.14.0\" or \"0.15.0-SNAPSHOT\"\n */\npublic class IcebergVersionFunction implements UnboundFunction {\n  @Override\n  public BoundFunction bind(StructType inputType) {\n    if (inputType.fields().length > 0) {\n      throw new UnsupportedOperationException(\n          String.format(\"Cannot bind: %s does not accept arguments\", name()));\n    }\n\n    return new IcebergVersionFunctionImpl();\n  }\n\n  @Override\n  public String description() {\n    return name() + \" - Returns the runtime Iceberg version\";\n  }\n\n  @Override\n  public String name() {\n    return \"iceberg_version\";\n  }\n\n  // Implementing class cannot be private, otherwise Spark is unable to access the static invoke\n  // function during code-gen and calling the function fails","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/functions/IcebergVersionFunction.java#L20-L56","documentation":"iceberg_version() is a zero-argument system function that returns the Iceberg runtime version string. Its bind() rejects any invocation with one or more arguments because the function accepts no inputs.","triggerScenarios":"Calling iceberg.iceberg_version(x) with any argument — whether a column, literal, or accidental parameter from dynamic SQL generation.","commonSituations":"Copy-pasting a different function's call shape; code generators that uniformly append a column argument; confusing iceberg_version() with functions like current_timestamp().","solutions":["Call it with no arguments: SELECT iceberg.iceberg_version();","Remove any accidental argument from generated or templated SQL.","If you need a version of something else, use the appropriate metadata function or catalog API."],"exampleFix":"// before\nSELECT iceberg.iceberg_version(table_name) FROM t;\n// after\nSELECT iceberg.iceberg_version();","handlingStrategy":"validation","validationCode":"-- call with zero args only\nSELECT iceberg.iceberg_version();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember iceberg_version() is zero-argument — never parameterize it","Sanitize generated SQL so column arguments are not appended to zero-arg functions"],"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"}