apache/druid · error · ExpressionValidationException
Function[%s] %s
Error message
Function[%s] %s
What it means
NamedFunction.validationFailed is the standard helper for a function implementation to report validation failure; it throws ExpressionValidationException prefixed with Function[<name>]. The %s %s message means the second %s carries the function-specific reason (e.g. wrong argument count). Thrown during expression validation (Parser.validateExpr / planning validation) when arguments are invalid.
Source
Thrown at processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java:46
* Common stuff for "named" functions of "functional" expressions, such as {@link FunctionExpr},
* {@link ApplyFunctionExpr}, and {@link ExprMacroTable.ExprMacroFunctionExpr}.
*
* Provides helper methods for performing common validation operations to help reduce boilerplate for implementors and
* make it easier to provide consistent error messaging.
*/
public interface NamedFunction
{
/**
* Name of the function
*/
String name();
/**
* Helper method for creating a {@link ExpressionValidationException} with the specified reason
*/
default ExpressionValidationException validationFailed(String reasonFormat, Object... args)
{
throw new ExpressionValidationException(this, reasonFormat, args);
}
default ExpressionValidationException validationFailed(Throwable e, String reasonFormat, Object... args)
{
throw new ExpressionValidationException(this, e, reasonFormat, args);
}
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);
}
/**View on GitHub (pinned to 9b90983fd2)
Solutions
- Read the reason after 'Function[name]' and correct the expression arguments (count/order/literal-ness).
- Check the function's documentation for its exact required signature.
- If authoring a function, ensure validation helpers are called with the right expected counts in validate().
Example fix
// before
Expr e = Parser.parse("abs(x, 2)", null); // Function[abs] requires 1 argument
// after
Expr e = Parser.parse("abs(x)", null); Defensive patterns
Strategy: try-catch
Validate before calling
// check arity before parsing/validating
if (args.size() != expectedCount) throw new IllegalArgumentException("fn expects " + expectedCount + " args"); Try / catch
try { Parser.validateExpr(expr, analysis); } catch (ExpressionValidationException e) { log.error("{}: {}", e.getFunctionName(), e.getMessage()); } Prevention
- Consult the function docs for exact arity before writing expressions
- Validate expressions in CI with Parser.parse/validateExpr
- Watch for arity changes across Druid upgrades in custom functions
When it happens
Trigger: Calling validationHelperCheckArgumentCount / CheckMinArgumentCount / CheckAnyOfArgumentCount / CheckArgIsLiteral inside a NamedFunction's validation when the supplied args violate the contract — e.g. writing "abs(a, b)" (too many args) or passing a non-literal where a literal is required.
Common situations: Typo in SQL/native expression function arity; using array functions like array_offset with wrong argument counts; passing a dynamic expression where a constant is mandated; custom extension functions with stricter validation after a Druid upgrade.
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
- must have an even number of arguments
- must have at least two arguments
- Expression %s has non-constant inputs.
- Failed to parse expression: %s
- Unable to transform apply function:[%s]
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/fec0fc2aefe7fa40.
Report an issue: GitHub.