{"record":{"id":"9a68337fe3c8b6db","repo":"apache/iceberg","slug":"too-many-arguments-for-procedure","errorCode":null,"errorMessage":"Too many arguments for procedure","messagePattern":"Too many arguments for procedure","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveProcedures.scala","lineNumber":157,"sourceCode":"    val validationErrors = namedArgs.groupBy(_.name).collect {\n      case (name, matchingArgs) if matchingArgs.size > 1 => s\"Duplicate procedure argument: $name\"\n      case (name, _) if !nameToPositionMap.contains(name) => s\"Unknown argument: $name\"\n    }\n\n    if (validationErrors.nonEmpty) {\n      throw new AnalysisException(\n        s\"Could not build name to arg map: ${validationErrors.mkString(\", \")}\")\n    }\n\n    namedArgs.map(arg => arg.name -> arg).toMap\n  }\n\n  private def buildNameToArgMapUsingPositions(\n      args: Seq[CallArgument],\n      params: Seq[ProcedureParameter]): Map[String, CallArgument] = {\n\n    if (args.size > params.size) {\n      throw new AnalysisException(\"Too many arguments for procedure\")\n    }\n\n    args.zipWithIndex.map { case (arg, position) =>\n      val param = params(position)\n      param.name -> arg\n    }.toMap\n  }\n\n  private def normalizeParams(params: Seq[ProcedureParameter]): Seq[ProcedureParameter] = {\n    params.map {\n      case param if param.required =>\n        val normalizedName = param.name.toLowerCase(Locale.ROOT)\n        ProcedureParameter.required(normalizedName, param.dataType)\n      case param =>\n        val normalizedName = param.name.toLowerCase(Locale.ROOT)\n        ProcedureParameter.optional(normalizedName, param.dataType)\n    }\n  }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveProcedures.scala#L139-L175","documentation":"Analysis-time validation in ResolveProcedures (Spark extensions): a CALL statement passed more positional arguments than the procedure declares parameters. It fires during analysis while binding procedure arguments — before execution — so the SQL itself must be corrected (drop extra arguments or use valid named arguments).","triggerScenarios":"CALL catalog.system.proc(a, b, c) against a procedure that declares only 2 parameters, using positional (unnamed) arguments.","commonSituations":"Copy-pasted CALL statements from docs for a different procedure version; invoking a procedure on an older Iceberg/Spark build whose signature has fewer parameters.","solutions":["Remove the extra arguments so the count matches the procedure's declared parameters","Switch to named arguments to make each value's target parameter explicit and catch the mismatch immediately","Verify the procedure signature on your installed Iceberg version — it may differ from the documentation you copied"],"exampleFix":"// before\nCALL catalog.system.expire_snapshots('db.t', TIMESTAMP '2020-01-01', 100, true)\n// after\nCALL catalog.system.expire_snapshots(table => 'db.t', older_than => TIMESTAMP '2020-01-01')","handlingStrategy":"validation","validationCode":"val positionalArgs = callArgs.filterNot(_.isInstanceOf[NamedArgument])\nrequire(positionalArgs.size <= procedureParams.size,\n  s\"${positionalArgs.size} args for ${procedureParams.size} params\")","typeGuard":null,"tryCatchPattern":"try { spark.sql(callSql) } catch { case e: AnalysisException if e.getMessage == \"Too many arguments for procedure\" => // drop extras or use named args }","preventionTips":["Verify the procedure's arity on your installed Iceberg version before copying example CALLs","Prefer named arguments so extra/missing parameters fail with precise messages"],"tags":["spark","sql","call-procedure","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-23T08:17:48.524Z"}