{"record":{"id":"0452fc1046a67c37","repo":"apache/druid","slug":"requires-s-arguments","errorCode":null,"errorMessage":"requires %s arguments","messagePattern":"requires (.+?) arguments","errorType":"validation","errorClass":"DruidException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java","lineNumber":112,"sourceCode":"    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\",\n          Strings.join(\" or \", () -> Arrays.stream(counts).mapToObj(String::valueOf).iterator())\n      );\n    }\n  }\n\n  /**\n   * Helper method for implementors performing validation to check that an argument is a literal\n   */\n  default void validationHelperCheckArgIsLiteral(Expr arg, String argName)\n  {\n    if (!arg.isLiteral()) {\n      throw validationFailed(\n          \"%s argument must be a literal\",\n          argName\n      );\n    }\n  }","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java#L94-L130","documentation":"Generic argument-count guard used by Druid's named expression functions: validationHelperCheckAnyOfArgumentCount fires when a function that accepts several fixed possible argument counts (e.g. 1 or 2) is called with a count matching none of them. It is a sentinel message from the shared validation helper, listing the acceptable counts joined by 'or'; correct the function call so its argument count matches one of the allowed options.","triggerScenarios":"Calling a function declared with validationHelperCheckAnyOfArgumentCount(args, 1, 3) (say) with 2 arguments.","commonSituations":"Overload-style native functions where SQL translation picked the wrong overload shape, hand-written expressions guessing arity.","solutions":["Pass exactly one of the accepted argument counts listed in the message","Check the function source to see the accepted counts","Use the matching overload or pad/trim arguments accordingly"],"exampleFix":"// before\nx = timestamp_shift(d, p)  // accepts 3 or 4\n// after\nx = timestamp_shift(d, p, 'UTC')","handlingStrategy":"validation","validationCode":"java.util.Arrays.sort(allowed); if (java.util.Arrays.binarySearch(allowed, args.size()) < 0) { throw new IllegalArgumentException(funcName + \" accepts arguments counts \" + java.util.Arrays.toString(allowed) + \", got \" + args.size()); }","typeGuard":"boolean arityIsAnyOf(List<Expr> args, int... counts) { for (int c : counts) { if (args.size() == c) return true; } return false; }","tryCatchPattern":"try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // map to the closest supported overload }","preventionTips":["Pick the correct overload up front","Test each accepted arity variant","Keep overload selection logic in one place"],"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"}