{"record":{"id":"667795bcea83d9ce","repo":"apache/druid","slug":"requires-1-argument","errorCode":null,"errorMessage":"requires 1 argument","messagePattern":"requires 1 argument","errorType":"validation","errorClass":"ExpressionValidationException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java","lineNumber":73,"sourceCode":"  {\n    throw new ExpressionProcessingException(this, reasonFormat, args);\n  }\n\n  default ExpressionProcessingException processingFailed(Throwable e, String reasonFormat, Object... args)\n  {\n    throw new ExpressionProcessingException(this, e, reasonFormat, args);\n  }\n\n  /**\n   * Helper method for implementors performing validation to check if the argument count is expected\n   */\n  default void validationHelperCheckArgumentCount(List<Expr> args, int count)\n  {\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","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java#L55-L91","documentation":"Druid's expression function validation throws this when a NamedFunction implementation that expects exactly one argument receives a different number of arguments. The validationHelperCheckArgumentCount helper on NamedFunction compares args.size() against the declared count and throws validationFailed. It is thrown at query parsing/planning time, before evaluation.","triggerScenarios":"Calling an expression function that declares validationHelperCheckArgumentCount(args, 1) with 0 arguments (e.g. a single-argument function like CEIL invoked as CEIL()) or with 2+ arguments (e.g. CEIL(x, y)).","commonSituations":"Typos in SQL/native expressions, copy-pasted expressions with leftover arguments, dynamic expression builders concatenating extra operands, or SQL dialect translations producing wrong arity.","solutions":["Count the arguments passed to the function and pass exactly one","Check the function's validation in its NamedFunction implementation to confirm expected arity","If a two-argument form is intended, use a function variant that supports it (e.g. a function accepting a range of counts)"],"exampleFix":"// before\nlong_value = ceil()\n// after\nlong_value = ceil(value_expr)","handlingStrategy":"validation","validationCode":"if (args.size() != 1) { throw new IllegalArgumentException(funcName + \" requires exactly 1 argument, got \" + args.size()); }","typeGuard":"boolean isSingleArg(List<Expr> args) { return args != null && args.size() == 1; }","tryCatchPattern":"try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { log.error(\"Bad expression arity: %s\", e.getMessage()); throw new QueryPlanningException(e); }","preventionTips":["Count operands before calling single-argument functions","Consult the function's NamedFunction validation to confirm arity","Add unit tests for dynamically built expressions"],"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"}