{"record":{"id":"c9fc41e665e88584","repo":"apache/druid","slug":"requires-at-least-1-argument","errorCode":null,"errorMessage":"requires at least 1 argument","messagePattern":"requires at least 1 argument","errorType":"validation","errorClass":"ExpressionValidationException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java","lineNumber":86,"sourceCode":"  {\n    if (args.size() != count) {\n      if (count == 0) {\n        throw validationFailed(\"does not accept arguments\");\n      } else if (count == 1) {\n        throw validationFailed(\"requires 1 argument\");\n      }\n      throw validationFailed(\"requires %d arguments\", count);\n    }\n  }\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;","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java#L68-L104","documentation":"Generic argument-count guard used by Druid's named expression functions: validationHelperCheckMinArgumentCount(args, 1) fires when a SQL/Druid expression function that requires at least one argument (e.g. a string, arithmetic, or aggregation helper function) is invoked with zero arguments. It is a sentinel message from a shared validation helper, not function-specific logic; the fix is to supply the required argument(s) at the call site, e.g. CHANGE to CONCAT(x, ...) instead of empty parentheses.","triggerScenarios":"Invoking a variadic-or-minimum function such as GREATEST, CONCAT, or array functions with an empty argument list.","commonSituations":"Building expressions programmatically with an empty operand list; SQL like CONCAT() generated from zero folded inputs.","solutions":["Pass at least one argument","Guard the call site: skip the function entirely when the operand list is empty","Check the function's validation to confirm the minimum"],"exampleFix":"// before\nexpr = concat()\n// after\nexpr = concat(a, b)","handlingStrategy":"validation","validationCode":"if (args.isEmpty()) { throw new IllegalArgumentException(funcName + \" requires at least 1 argument\"); }","typeGuard":"boolean hasMinArity(List<Expr> args, int min) { return args != null && args.size() >= min; }","tryCatchPattern":"try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // handle empty-argument expressions by substituting a default }","preventionTips":["Skip variadic calls when the operand list is empty","Fold empty collections into defaults before expression building","Parse user expressions early and fail with a clear message"],"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"}