apache/cassandra · error · InvalidRequestException
Unknown function called in selection clause
Error message
Unknown function %s called in selection clause
What it means
FunctionResolver returned a function object but its return type is null, which happens for functions that cannot be used as expressions producing a value. Such functions are not valid in a selection clause and are rejected after the unknown-name check.
Solutions
- Use a function with a concrete return type in the SELECT clause
- Move side-effecting or void calls out of the query entirely
- Replace with an equivalent aggregate or scalar function that returns a value
Example fix
// before SELECT someVoidFn(x) FROM t; // after SELECT x FROM t; // drop the non-returning call
Defensive patterns
Strategy: validation
Validate before calling
// only call functions with a non-null return type if (fn.returnType() == null) throw new IllegalArgumentException(fn + " returns no value");
Prevention
- Use only value-returning functions in projections
- Consult function docs for return types before use
- Keep side-effecting calls out of SELECT clauses
When it happens
Trigger: Calling a null-returning function (e.g. certain internal/void-returning functions) inside SELECT fn(...) FROM t.
Common situations: Users try to invoke token-like, mutation-style, or otherwise non-returning native functions in the projection; these are not valid selector expressions.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- is not a valid Transformation.Kind id
- In call to function , value 0x is not a valid binary…
- Masking function return type is . This is different to the…
- No receiver keyspace has been specified for function
- No receiver table has been specified for function
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/a183969f09ee5ef2.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/selection/Selectable.java:456
// argument outside of check for nullness) and for backward compatibilty we want to support COUNT(1),
// but we actually have COUNT(x) method for every existing (simple) input types so currently COUNT(1)
// will throw as ambiguous (since 1 works for any type). So we have to special case COUNT.
if (functionName.equalsNativeFunction(FunctionName.nativeFunction("count"))
&& preparedArgs.size() == 1
&& (preparedArgs.get(0) instanceof WithTerm)
&& (((WithTerm)preparedArgs.get(0)).rawTerm instanceof Constants.Literal))
{
// Note that 'null' isn't a Constants.Literal
name = AggregateFcts.countRowsFunction.name();
preparedArgs = Collections.emptyList();
}
Function fun = FunctionResolver.get(table.keyspace, name, preparedArgs, table.keyspace, table.name, null, UserFunctions.getCurrentUserFunctions(name, table.keyspace));
if (fun == null)
throw new InvalidRequestException(String.format("Unknown function '%s'", functionName));
if (fun.returnType() == null)
throw new InvalidRequestException(String.format("Unknown function %s called in selection clause", functionName));
return new WithFunction(fun, preparedArgs);
}
}
}
public static class WithCast implements Selectable
{
private final CQL3Type type;
private final Selectable arg;
public WithCast(Selectable arg, CQL3Type type)
{
this.arg = arg;
this.type = type;
}
@OverrideView on GitHub (pinned to 88fd0f6a0e)