apache/druid · error · ExpressionValidationException

does not accept arguments

Error message

does not accept arguments

What it means

Generic Druid expression validation raised by validationHelperCheckArgumentCount: a function declared to take exactly 0 arguments (count == 0) was invoked with one or more arguments. The function family (e.g. zero-arg builtins like CURRENT_TIMESTAMP-style functions) never accepts parameters, so any supplied arguments cause this validation failure.

Source

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

  default ExpressionProcessingException processingFailed(String reasonFormat, Object... args)
  {
    throw new ExpressionProcessingException(this, reasonFormat, args);
  }

  default ExpressionProcessingException processingFailed(Throwable e, String reasonFormat, Object... args)
  {
    throw new ExpressionProcessingException(this, e, reasonFormat, args);
  }

  /**
   * Helper method for implementors performing validation to check if the argument count is expected
   */
  default void validationHelperCheckArgumentCount(List<Expr> args, int count)
  {
    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);
    }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Remove all arguments: call the function with empty parentheses, e.g. fn().
  2. Check the function name — you may want a different, parameterized function.
  3. If arguments were added by a query builder/template, fix the template for this function.
  4. Consult the Druid expression function reference for the correct arity.

Example fix

// before
some_zero_arg_fn('extra')
// after
some_zero_arg_fn()
Defensive patterns

Strategy: validation

Validate before calling

// check arity before invoking
if (argCount > 0 && functionTakesZeroArgs(name)) throw new IllegalArgumentException(name + "() takes no arguments");

Type guard

// reject any non-empty argument list for zero-arg functions
if (args.length !== 0) reject();

Prevention

When it happens

Trigger: Calling a zero-argument named function with arguments, e.g. zerofn('x') or zerofn(col), including accidental argument passing from generic query builders or macro expansion.

Common situations: Copy-paste from another SQL dialect where the same-name function takes parameters; template-generated SQL appending unused arguments; confusion between a zero-arg function and a similarly named parameterized one.

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