{"record":{"id":"f222485271baab23","repo":"apache/cassandra","slug":"ambiguous-call-to-function-s-can-be-matched-by-f","errorCode":null,"errorMessage":"Ambiguous call to function %s (can be matched by following signatures: %s): use type casts to disambiguate","messagePattern":"Ambiguous call to function (.+?) \\(can be matched by following signatures: (.+?)\\): use type casts to disambiguate","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java","lineNumber":187,"sourceCode":"            if (OperationFcts.isOperation(name))\n            {\n                if (receiverType != null && !containsMarkers(providedArgs))\n                {\n                    for (Function toTest : compatibles)\n                    {\n                        List<AbstractType<?>> argTypes = toTest.argTypes();\n                        if (receiverType.equals(argTypes.get(0)) && receiverType.equals(argTypes.get(1)))\n                            return toTest;\n                    }\n                }\n                throw invalidRequest(\"Ambiguous '%s' operation with args %s and %s: use type hint to disambiguate, example '(int) ?'\",\n                                     OperationFcts.getOperator(name), providedArgs.get(0), providedArgs.get(1));\n            }\n\n            if (OperationFcts.isNegation(name))\n                throw invalidRequest(\"Ambiguous negation: use type casts to disambiguate\");\n\n            throw invalidRequest(\"Ambiguous call to function %s (can be matched by following signatures: %s): use type casts to disambiguate\",\n                                 name, format(compatibles));\n        }\n\n        return compatibles.get(0);\n    }\n\n    /**\n     * Checks if at least one of the specified arguments is a marker.\n     *\n     * @param args the arguments to check\n     * @return {@code true} if if at least one of the specified arguments is a marker, {@code false} otherwise\n     */\n    private static boolean containsMarkers(List<? extends AssignmentTestable> args)\n    {\n        return args.stream().anyMatch(Marker.Raw.class::isInstance);\n    }\n\n    /**","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java#L169-L205","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: matches both (int,int) and (float,float) overloads\nSELECT myfun(1, 2) FROM t;\n// after\ndatastax session.execute(\"SELECT myfun((int)1, (int)2) FROM t\");","handlingStrategy":"validation","validationCode":"// before creating a new UDF overload, check for coercible overlap\n// SELECT function_name, argument_types FROM system_schema.functions WHERE keyspace_name = 'ks' AND function_name = 'myfun';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cql","function-resolution","ambiguity"],"backgroundTag":"invalid-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}