apache/druid · error · ExpressionValidationException

requires at least %d arguments

Error message

requires at least %d arguments

What it means

Generic argument-count guard used by Druid's named expression functions: validationHelperCheckMinArgumentCount(args, count) fires when a function requiring at least 'count' arguments is called with fewer. The message is a template from the shared validation helper naming the minimum required count. It indicates a malformed expression call site (too few arguments), not a data error; supply at least the required number of arguments in the SQL/expression.

Source

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

      if (count == 0) {
        throw validationFailed("does not accept arguments");
      } else if (count == 1) {
        throw validationFailed("requires 1 argument");
      }
      throw validationFailed("requires %d arguments", count);
    }
  }

  /**
   * 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) {

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Provide at least N arguments
  2. Inspect the function implementation for the declared minimum
  3. Split the logic or use a different function if fewer operands are genuinely available

Example fix

// before
x = substring(str)  // requires at least 2
// after
x = substring(str, 1, 3)
Defensive patterns

Strategy: validation

Validate before calling

if (args.size() < minCount) { throw new IllegalArgumentException(funcName + " requires at least " + minCount + " arguments, got " + args.size()); }

Type guard

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

Try / catch

try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // report missing operands with expected minimum }

Prevention

When it happens

Trigger: Calling e.g. a function declared with validationHelperCheckMinArgumentCount(args, 3) with only 2 arguments.

Common situations: Omitting required trailing operands, partial dynamic expression assembly, or misreading variadic functions as fully optional.

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/456476e757fa9e36. Report an issue: GitHub.