apache/druid · error · ExpressionValidationException
argument must be a LONG constant
Error message
argument must be a LONG constant
What it means
The bloom_filter_expr / bloom_filter_operand macro requires its single argument (the expected filter size) to be a literal LONG constant. If the argument is not a literal or has a null literal value, expression validation fails with 'argument must be a LONG constant'.
Solutions
- Pass a constant integer literal, e.g. bloom_filter_expr(1000).
- Remove any dynamic (non-literal) expression from the argument.
- Ensure the literal is a number, not a string, and not NULL.
Example fix
// before SELECT bloom_filter_expr(col_size) FROM t // after SELECT bloom_filter_expr(1000) FROM t
Defensive patterns
Strategy: validation
Validate before calling
// validate args before building the expression
if (args.size() != 1 || !args.get(0).isLiteral() || !(args.get(0).getLiteralValue() instanceof Number)) {
throw new IllegalArgumentException("expected a LONG literal, e.g. bloom_filter_expr(1000)");
} Type guard
boolean isValidSizeArg(Expr e) { return e != null && e.isLiteral() && e.getLiteralValue() != null && e.getLiteralValue() instanceof Number; } Prevention
- Always pass a numeric constant as the expected size
- Do not substitute columns or session parameters for the size
- Document macro signature in SQL builder wrappers
When it happens
Trigger: Calling BLOOM_FILTER_EXPECTED_SIZE-like macros with a non-literal expression (e.g., a column reference or computed expression) or a null literal as the size argument.
Common situations: Passing a column or query parameter instead of a constant integer; forgetting the argument defaults expectation; using a string literal instead of a number.
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
- Failed to deserialize bloom filter
- attempt to get boolean[] null vector from string[] only…
- attempt to get double[] from string[] only scalar binding
- attempt to get long[] from string[] only scalar binding
- bf1Length does not match bf2Length
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/3690d4a4ea0d6672.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/druid-bloom-filter/src/main/java/org/apache/druid/query/expressions/BloomFilterExpressions.java:62
public static class CreateExprMacro implements ExprMacroTable.ExprMacro
{
public static final String FN_NAME = "bloom_filter";
@Override
public String name()
{
return FN_NAME;
}
@Override
public Expr apply(List<Expr> args)
{
validationHelperCheckArgumentCount(args, 1);
final Expr expectedSizeArg = args.get(0);
if (!expectedSizeArg.isLiteral() || expectedSizeArg.getLiteralValue() == null) {
throw validationFailed("argument must be a LONG constant");
}
class BloomExpr extends ExprMacroTable.BaseScalarMacroFunctionExpr
{
final int expectedSize;
public BloomExpr(List<Expr> args)
{
super(CreateExprMacro.this, args);
this.expectedSize = args.get(0).eval(InputBindings.nilBindings()).asInt();
}
@Override
public ExprEval eval(ObjectBinding bindings)
{
return ExprEval.ofComplex(
BLOOM_FILTER_TYPE,
new BloomKFilter(expectedSize)View on GitHub (pinned to 9b90983fd2)