{"record":{"id":"8e8e31bd2c140cc6","repo":"apache/cassandra","slug":"unknown-function-s","errorCode":null,"errorMessage":"Unknown function '%s'","messagePattern":"Unknown function '(.+?)'","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/selection/Selectable.java","lineNumber":453,"sourceCode":"\n                FunctionName name = functionName;\n                // COUNT(x) is equivalent to COUNT(*) for any non-null term x (since count(x) don't care about its\n                // argument outside of check for nullness) and for backward compatibilty we want to support COUNT(1),\n                // but we actually have COUNT(x) method for every existing (simple) input types so currently COUNT(1)\n                // will throw as ambiguous (since 1 works for any type). So we have to special case COUNT.\n                if (functionName.equalsNativeFunction(FunctionName.nativeFunction(\"count\"))\n                        && preparedArgs.size() == 1\n                        && (preparedArgs.get(0) instanceof WithTerm)\n                        && (((WithTerm)preparedArgs.get(0)).rawTerm instanceof Constants.Literal))\n                {\n                    // Note that 'null' isn't a Constants.Literal\n                    name = AggregateFcts.countRowsFunction.name();\n                    preparedArgs = Collections.emptyList();\n                }\n                Function fun = FunctionResolver.get(table.keyspace, name, preparedArgs, table.keyspace, table.name, null, UserFunctions.getCurrentUserFunctions(name, table.keyspace));\n\n                if (fun == null)\n                    throw new InvalidRequestException(String.format(\"Unknown function '%s'\", functionName));\n\n                if (fun.returnType() == null)\n                    throw new InvalidRequestException(String.format(\"Unknown function %s called in selection clause\", functionName));\n\n                return new WithFunction(fun, preparedArgs);\n            }\n        }\n    }\n\n    public static class WithCast implements Selectable\n    {\n        private final CQL3Type type;\n        private final Selectable arg;\n\n        public WithCast(Selectable arg, CQL3Type type)\n        {\n            this.arg = arg;\n            this.type = type;","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/selection/Selectable.java#L435-L471","documentation":"When preparing a function call in the SELECT clause, FunctionResolver.get found no native or user function matching the name and argument types. The code translates a null resolver result into this InvalidRequestException.","triggerScenarios":"SELECT unknown_fn(col) FROM t — the function name is misspelled, defined in another keyspace, or arg types match no overload.","commonSituations":"Typo in aggregate/native function names, calling a UDA/UDF created in a different keyspace without qualification, or a function dropped before the query runs.","solutions":["Correct the function name (check DESCRIBE FUNCTIONS / system_schema.functions)","Qualify with the keyspace: SELECT ks.fn(col) FROM ...","Create the UDF/UDA in the current keyspace before running the query"],"exampleFix":"// before\nSELECT avrg(x) FROM t;\n// after\nSELECT avg(x) FROM t;","handlingStrategy":"try-catch","validationCode":"// pre-check availability\nRow r = session.execute(\"SELECT function_name FROM system_schema.functions WHERE keyspace_name=?\", ks).one();","typeGuard":null,"tryCatchPattern":"try { stmt = session.prepare(sql); }\ncatch (InvalidRequestException e) {\n  if (e.getMessage().contains(\"Unknown function\")) { /* register/qualify the function and retry */ }\n  throw e;\n}","preventionTips":["Qualify UDFs with their keyspace","Run DESCRIBE FUNCTIONS after schema changes","Watch for typos in native function names"],"tags":["cql","function","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}