{"record":{"id":"fb5ef9d334d3ad2d","repo":"apache/cassandra","slug":"function-s-doesn-t-exist","errorCode":null,"errorMessage":"Function '%s' doesn't exist","messagePattern":"Function '(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/DropFunctionStatement.java","lineNumber":94,"sourceCode":"        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n    }\n\n    @Override\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        String name =\n            argumentsSpeficied\n          ? format(\"%s.%s(%s)\", keyspaceName, functionName, join(\", \", transform(arguments, CQL3Type.Raw::toString)))\n          : format(\"%s.%s\", keyspaceName, functionName);\n\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n        {\n            if (ifExists)\n                return schema;\n\n            throw ire(\"Function '%s' doesn't exist\", name);\n        }\n\n        Collection<UserFunction> functions = keyspace.userFunctions.get(new FunctionName(keyspaceName, functionName));\n        if (functions.size() > 1 && !argumentsSpeficied)\n        {\n            throw ire(\"'DROP FUNCTION %s' matches multiple function definitions; \" +\n                      \"specify the argument types by issuing a statement like \" +\n                      \"'DROP FUNCTION %s (type, type, ...)'. You can use cqlsh \" +\n                      \"'DESCRIBE FUNCTION %s' command to find all overloads\",\n                      functionName, functionName, functionName);\n        }\n\n        arguments.stream()\n                 .filter(raw -> !raw.isImplicitlyFrozen() && raw.isFrozen())\n                 .findFirst()\n                 .ifPresent(t -> { throw ire(\"Argument '%s' cannot be frozen; remove frozen<> modifier from '%s'\", t, t); });\n\n        List<AbstractType<?>> argumentTypes = prepareArgumentTypes(keyspace.types);","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/DropFunctionStatement.java#L76-L112","documentation":"DROP FUNCTION failed because no user-defined function with the given name exists in the target keyspace (or the keyspace itself is absent) and IF EXISTS was not given. apply() checks current schema before removing anything.","triggerScenarios":"DROP FUNCTION ks.fn where ks or fn does not exist, without IF EXISTS.","commonSituations":"Typo in function or keyspace name; function already dropped; running DDL against a fresh environment lacking the UDF; case-sensitive quoted identifiers mismatch.","solutions":["Add IF EXISTS: DROP FUNCTION IF EXISTS ks.fn","Verify existence with SELECT function_name FROM system_schema.functions WHERE keyspace_name='ks';","Create the function first if the drop order in scripts is wrong"],"exampleFix":"// before\nDROP FUNCTION sales.my_func;\n// after\nDROP FUNCTION IF EXISTS sales.my_func;","handlingStrategy":"validation","validationCode":"const rows = await session.execute(\"SELECT function_name FROM system_schema.functions WHERE keyspace_name=? AND function_name=?\", [ks, name]); if (rows.rowLength === 0) return; // skip drop","typeGuard":null,"tryCatchPattern":"try { session.execute(`DROP FUNCTION IF EXISTS ${ks}.${name}`); } catch (e) { if (e instanceof InvalidQueryError && /doesn't exist/.test(e.message)) { /* treat as no-op */ } else throw e; }","preventionTips":["Use IF EXISTS for idempotent migrations","Verify UDF presence in system_schema.functions before dropping"],"tags":["cql","drop-function","not-found","udf"],"backgroundTag":"entity-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"}