apache/druid · error · ExpressionValidationException
argument should be an identifier expression. Use array()…
Error message
argument %s should be an identifier expression. Use array() instead
What it means
Thrown during argument validation when a Druid expression function requires its first (only) argument to be an identifier expression — i.e. a bare column reference — but receives an arbitrary expression. The message hints that if an array value was intended, the array() constructor should be used instead.
Solutions
- Pass a bare column identifier as the first argument, e.g. f(myColumn).
- If you meant to supply an array value, use the array() constructor: f(array(1, 2, 3)) as appropriate for the function.
- Materialize the intermediate expression into a new column (e.g. via a subquery/ingestion expression) and reference that column.
- Check the function's documentation to confirm it operates on identifiers (e.g. for special planning/index handling).
Example fix
// before some_fn(CONCAT(col, '_x')) // after some_fn(col)
Defensive patterns
Strategy: validation
Validate before calling
// only pass bare column references assert (!(arg instanceof Expr)) || arg instanceof Column; // API users: pass "col", not expressions
Type guard
// ensure first arg is a plain identifier, not a call or literal
if (arg.startsWith("(") || arg.contains("(")) reject(); Prevention
- Pass plain column names to identifier-requiring functions
- Use array(...) for array literals
- Materialize intermediate expressions in a subquery first
When it happens
Trigger: Calling the function with a computed expression, literal, or nested function call as the first argument, e.g. f(COALESCE(col, 'x')) or f('literal'), instead of a plain column name like f(col).
Common situations: Rewriting queries where the original wrapped the column in a function; users trying to pass an inline array literal with legacy syntax instead of array(1,2,3); query builders that auto-wrap columns.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- needs a positive integer as the second argument
- needs an integer as the second argument
- Cannot cast [ ] to [ ] (Types.InvalidCastException from…
- Cannot find strategy for type
- Cannot implicitly cast
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/7f781880523941dc.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/math/expr/Function.java:3318
public String name()
{
return "mv_to_array";
}
@Override
public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
{
return args.get(0).eval(bindings).castTo(ExpressionType.STRING_ARRAY);
}
@Override
public void validateArguments(List<Expr> args)
{
validationHelperCheckArgumentCount(args, 1);
IdentifierExpr expr = args.get(0).getIdentifierExprIfIdentifierExpr();
if (expr == null) {
throw validationFailed(
"argument %s should be an identifier expression. Use array() instead",
args.get(0).toString()
);
}
}
@Nullable
@Override
public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<Expr> args)
{
return ExpressionType.STRING_ARRAY;
}
@Override
public boolean hasArrayInputs()
{
return true;
}View on GitHub (pinned to 9b90983fd2)