apache/druid · error · ExpressionValidationException

requires at least 1 argument

Error message

requires at least 1 argument

What it means

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.

Source

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

  {
    if (args.size() != count) {
      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;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Pass at least one argument
  2. Guard the call site: skip the function entirely when the operand list is empty
  3. Check the function's validation to confirm the minimum

Example fix

// before
expr = concat()
// after
expr = concat(a, b)
Defensive patterns

Strategy: validation

Validate before calling

if (args.isEmpty()) { throw new IllegalArgumentException(funcName + " requires at least 1 argument"); }

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) { // handle empty-argument expressions by substituting a default }

Prevention

When it happens

Trigger: Invoking a variadic-or-minimum function such as GREATEST, CONCAT, or array functions with an empty argument list.

Common situations: Building expressions programmatically with an empty operand list; SQL like CONCAT() generated from zero folded inputs.

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