apache/cassandra · error · InvalidRequestException
Ambiguous call to function %s (can be matched by following s
Error message
Ambiguous call to function %s (can be matched by following signatures: %s): use type casts to disambiguate
What it means
The generic ambiguity error of FunctionResolver: more than one function overload (compatibles) matched the provided argument types, no receiver type narrows it, and it isn't an operator/negation case. Cassandra lists all matching signatures and asks for explicit type casts to disambiguate rather than guessing.
Source
Thrown at src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java:187
if (OperationFcts.isOperation(name))
{
if (receiverType != null && !containsMarkers(providedArgs))
{
for (Function toTest : compatibles)
{
List<AbstractType<?>> argTypes = toTest.argTypes();
if (receiverType.equals(argTypes.get(0)) && receiverType.equals(argTypes.get(1)))
return toTest;
}
}
throw invalidRequest("Ambiguous '%s' operation with args %s and %s: use type hint to disambiguate, example '(int) ?'",
OperationFcts.getOperator(name), providedArgs.get(0), providedArgs.get(1));
}
if (OperationFcts.isNegation(name))
throw invalidRequest("Ambiguous negation: use type casts to disambiguate");
throw invalidRequest("Ambiguous call to function %s (can be matched by following signatures: %s): use type casts to disambiguate",
name, format(compatibles));
}
return compatibles.get(0);
}
/**
* Checks if at least one of the specified arguments is a marker.
*
* @param args the arguments to check
* @return {@code true} if if at least one of the specified arguments is a marker, {@code false} otherwise
*/
private static boolean containsMarkers(List<? extends AssignmentTestable> args)
{
return args.stream().anyMatch(Marker.Raw.class::isInstance);
}
/**View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Add explicit casts to the arguments so only one signature matches: f((int)1, (int)2)
- Drop or rename the redundant UDF overload that created the ambiguity (DROP FUNCTION)
- Inspect the signature list in the message and pick the intended one, casting accordingly
- Where possible, pass typed columns/literals whose types exactly match one overload
Example fix
// before: matches both (int,int) and (float,float) overloads
SELECT myfun(1, 2) FROM t;
// after
datastax session.execute("SELECT myfun((int)1, (int)2) FROM t"); Defensive patterns
Strategy: validation
Validate before calling
// before creating a new UDF overload, check for coercible overlap // SELECT function_name, argument_types FROM system_schema.functions WHERE keyspace_name = 'ks' AND function_name = 'myfun';
Prevention
- Avoid registering UDF overloads with mutually coercible parameter types
- Cast literal arguments to exact overload types in generated queries
- Review the signature list in the error to identify overlapping overloads
When it happens
Trigger: Calling an overloaded native function (e.g. min/max/dateFloor-ish family, or a UDF registered with several overloads) with argument types that match 2+ signatures, e.g. a UDF overloaded for (int,int) and (float,float) called with two literals like f(1, 2) that can coerce either way.
Common situations: UDFs defined multiple times with coercibly-compatible parameter types; calls with untyped literals that fit several overloads; after adding a new overload that now overlaps an existing one.
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
- Invalid call to function %s, none of its type signatures mat
- Ambiguous '%s' operation with args %s and %s: use type hint
- Ambiguous negation: use type casts to disambiguate
- Invalid number of arguments in call to function %s: %d requi
- Type error: %s cannot be passed as argument %d of function %
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/f222485271baab23.
Report an issue: GitHub.