apache/druid · error · ExpressionValidationException
requires 1 argument
Error message
requires 1 argument
What it means
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.
Source
Thrown at processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java:73
{
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
- 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)
Example fix
// before long_value = ceil() // after long_value = ceil(value_expr)
Defensive patterns
Strategy: validation
Validate before calling
if (args.size() != 1) { throw new IllegalArgumentException(funcName + " requires exactly 1 argument, got " + args.size()); } Type guard
boolean isSingleArg(List<Expr> args) { return args != null && args.size() == 1; } Try / catch
try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { log.error("Bad expression arity: %s", e.getMessage()); throw new QueryPlanningException(e); } Prevention
- Count operands before calling single-argument functions
- Consult the function's NamedFunction validation to confirm arity
- Add unit tests for dynamically built expressions
When it happens
Trigger: 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)).
Common situations: Typos in SQL/native expressions, copy-pasted expressions with leftover arguments, dynamic expression builders concatenating extra operands, or SQL dialect translations producing wrong arity.
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
- requires %d arguments
- requires at least 1 argument
- requires at least %d arguments
- requires %d to %d arguments
- requires %s arguments
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/667795bcea83d9ce.
Report an issue: GitHub.