apache/druid · error · DruidException

requires %d to %d arguments

Error message

requires %d to %d arguments

What it means

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.

Source

Thrown at processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java:95

  }

  /**
   * Helper method for implementors performing validation to check if there are at least as many arguments as specified
   */
  default void validationHelperCheckMinArgumentCount(List<Expr> args, int count)
  {
    if (args.size() < count) {
      if (count == 1) {
        throw validationFailed("requires at least 1 argument");
      }
      throw validationFailed("requires at least %d arguments", count);
    }
  }

  default void validationHelperCheckArgumentRange(List<Expr> args, int start, int end)
  {
    if (args.size() < start || args.size() > end) {
      throw validationFailed("requires %d to %d arguments", start, end);
    }
  }

  /**
   * Helper method for implementors performing validation to check if argument count is any of specified counts
   */
  default void validationHelperCheckAnyOfArgumentCount(List<Expr> args, int... counts)
  {
    boolean satisfied = false;
    for (int count : counts) {
      if (args.size() == count) {
        satisfied = true;
        break;
      }
    }
    if (!satisfied) {
      throw validationFailed(
          "requires %s arguments",

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Pass an argument count within the declared [min, max] range
  2. Check the function source for the validationHelperCheckArgumentRange call to see the bounds
  3. Drop optional extra arguments or add the missing ones

Example fix

// before
x = power(a, b, c)  // accepts 1 to 2
// after
x = power(a, b)
Defensive patterns

Strategy: validation

Validate before calling

if (args.size() < min || args.size() > max) { throw new IllegalArgumentException(funcName + " accepts " + min + " to " + max + " arguments, got " + args.size()); }

Type guard

boolean arityInRange(List<Expr> args, int min, int max) { return args != null && args.size() >= min && args.size() <= max; }

Try / catch

try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // trim optional args or report range violation }

Prevention

When it happens

Trigger: 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.

Common situations: Over-applying optional-parameter style functions in native expressions, translation layers adding extra implicit arguments.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/1820a73ecd8f02d8. Report an issue: GitHub.