{"record":{"id":"1820a73ecd8f02d8","repo":"apache/druid","slug":"requires-d-to-d-arguments","errorCode":null,"errorMessage":"requires %d to %d arguments","messagePattern":"requires (.+?) to (.+?) arguments","errorType":"validation","errorClass":"DruidException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java","lineNumber":95,"sourceCode":"  }\n\n  /**\n   * Helper method for implementors performing validation to check if there are at least as many arguments as specified\n   */\n  default void validationHelperCheckMinArgumentCount(List<Expr> args, int count)\n  {\n    if (args.size() < count) {\n      if (count == 1) {\n        throw validationFailed(\"requires at least 1 argument\");\n      }\n      throw validationFailed(\"requires at least %d arguments\", count);\n    }\n  }\n\n  default void validationHelperCheckArgumentRange(List<Expr> args, int start, int end)\n  {\n    if (args.size() < start || args.size() > end) {\n      throw validationFailed(\"requires %d to %d arguments\", start, end);\n    }\n  }\n\n  /**\n   * Helper method for implementors performing validation to check if argument count is any of specified counts\n   */\n  default void validationHelperCheckAnyOfArgumentCount(List<Expr> args, int... counts)\n  {\n    boolean satisfied = false;\n    for (int count : counts) {\n      if (args.size() == count) {\n        satisfied = true;\n        break;\n      }\n    }\n    if (!satisfied) {\n      throw validationFailed(\n          \"requires %s arguments\",","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java#L77-L113","documentation":"Generic argument-count guard used by Druid's named expression functions: validationHelperCheckArgumentRange fires when a function that accepts a bounded range of argument counts ([start, end]) receives fewer than start or more than end arguments. The message is a sentinel from the shared helper, with the accepted range filled in; the expression call site passed the wrong number of arguments and must be adjusted to within the stated range.","triggerScenarios":"Calling a function declared with validationHelperCheckArgumentRange(args, min, max) with fewer than min or more than max arguments, e.g. a function accepting 1-2 arguments called with 3.","commonSituations":"Over-applying optional-parameter style functions in native expressions, translation layers adding extra implicit arguments.","solutions":["Pass an argument count within the declared [min, max] range","Check the function source for the validationHelperCheckArgumentRange call to see the bounds","Drop optional extra arguments or add the missing ones"],"exampleFix":"// before\nx = power(a, b, c)  // accepts 1 to 2\n// after\nx = power(a, b)","handlingStrategy":"validation","validationCode":"if (args.size() < min || args.size() > max) { throw new IllegalArgumentException(funcName + \" accepts \" + min + \" to \" + max + \" arguments, got \" + args.size()); }","typeGuard":"boolean arityInRange(List<Expr> args, int min, int max) { return args != null && args.size() >= min && args.size() <= max; }","tryCatchPattern":"try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // trim optional args or report range violation }","preventionTips":["Model optional parameters explicitly in builders","Verify translated SQL keeps arity within declared ranges","Document each function's arity window"],"tags":["expression","argument-count","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}