apache/cassandra · error · InvalidRequestException
Unknown function %s called
Error message
Unknown function %s called
What it means
FunctionCall.Raw.prepare() resolves the function name via FunctionResolver against the provided argument terms and current user functions. If the resolver returns null (no signature matches the name/args in that keyspace), the statement cannot be prepared and this InvalidRequestException is thrown.
Source
Thrown at src/java/org/apache/cassandra/cql3/functions/FunctionCall.java:162
}
public static Raw newNegation(Term.Raw raw)
{
FunctionName name = FunctionName.nativeFunction(OperationFcts.NEGATION_FUNCTION_NAME);
return new Raw(name, Collections.singletonList(raw));
}
public static Raw newCast(Term.Raw raw, CQL3Type type)
{
FunctionName name = FunctionName.nativeFunction(CastFcts.getFunctionName(type));
return new Raw(name, Collections.singletonList(raw));
}
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type, UserFunctions.getCurrentUserFunctions(name, keyspace));
if (fun == null)
throw invalidRequest("Unknown function %s called", name);
if (fun.isAggregate())
throw invalidRequest("Aggregation function are not supported in the where clause");
ScalarFunction scalarFun = (ScalarFunction) fun;
// Functions.get() will complain if no function "name" type check with the provided arguments.
// We still have to validate that the return type matches however
if (!scalarFun.testAssignment(keyspace, receiver).isAssignable())
{
if (OperationFcts.isOperation(name))
throw invalidRequest("Type error: cannot assign result of operation %s (type %s) to %s (type %s)",
OperationFcts.getOperator(scalarFun.name()), scalarFun.returnType().asCQL3Type(),
receiver.name, receiver.type.asCQL3Type());
throw invalidRequest("Type error: cannot assign result of function %s (type %s) to %s (type %s)",
scalarFun.name(), scalarFun.returnType().asCQL3Type(),
receiver.name, receiver.type.asCQL3Type());
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Verify the function exists: SELECT * FROM system_schema.functions WHERE function_name = 'myfunc';
- Qualify the function with its keyspace: schema.myFunc(x)
- CREATE the function in the keyspace the query targets
- Fix typos and check the exact argument count/types match an existing overload
Example fix
// before SELECT myFunc(x) FROM t; // after SELECT ks.myFunc(x) FROM t; -- or create it first: CREATE FUNCTION ks.myFunc(x int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return x;';
Defensive patterns
Strategy: validation
Validate before calling
const known = (await session.execute("SELECT function_name FROM system_schema.functions WHERE keyspace_name = 'ks'")).rows.map(r => r.function_name);
if (!known.includes('myfunc')) throw new Error('function myfunc does not exist in ks'); Try / catch
try { rs = session.execute(q); } catch (InvalidRequestException e) { if (e.getMessage().startsWith('Unknown function')) { /* create/qualify function */ } else throw e; } Prevention
- Always keyspace-qualify UDF calls
- Deploy functions to all environments as part of schema migration
- Validate function names against system_schema.functions at startup
When it happens
Trigger: A function name in a SELECT/WHERE term that does not exist (or exists with an incompatible signature) in the target keyspace, e.g. `SELECT myFunc(x) FROM t` where myFunc was never CREATEd in that keyspace.
Common situations: Calling a user-defined function created in a different keyspace without qualifying it; typos in native function names; using an aggregate function name in a non-aggregate position; running against a cluster where the function was never deployed.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Type error: cannot assign result of function %s (type %s) to
- Invalid number of arguments for function %s
- Aggregation function are not supported in the where clause
- Type error: cannot assign result of operation %s (type %s) t
- Incorrect number of arguments specified for function %s (exp
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/74feb2f8ed9dca84.
Report an issue: GitHub.