apache/cassandra · error · InvalidRequestException
Function ' ' doesn't exist
Error message
Function '%s' doesn't exist
What it means
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.
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
Example fix
// before DROP FUNCTION sales.my_func; // after DROP FUNCTION IF EXISTS sales.my_func;
Defensive patterns
Strategy: validation
Validate before calling
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 Try / catch
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; } Prevention
- Use IF EXISTS for idempotent migrations
- Verify UDF presence in system_schema.functions before dropping
When it happens
Trigger: DROP FUNCTION ks.fn where ks or fn does not exist, without IF EXISTS.
Common situations: Typo in function or keyspace name; function already dropped; running DDL against a fresh environment lacking the UDF; case-sensitive quoted identifiers mismatch.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- 'DROP FUNCTION ' matches multiple function definitions…
- Aggregate ' ' doesn't exist
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- Cannot replace function
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/fb5ef9d334d3ad2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/DropFunctionStatement.java:94
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
}
@Override
public Keyspaces apply(ClusterMetadata metadata)
{
String name =
argumentsSpeficied
? format("%s.%s(%s)", keyspaceName, functionName, join(", ", transform(arguments, CQL3Type.Raw::toString)))
: format("%s.%s", keyspaceName, functionName);
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
if (null == keyspace)
{
if (ifExists)
return schema;
throw ire("Function '%s' doesn't exist", name);
}
Collection<UserFunction> functions = keyspace.userFunctions.get(new FunctionName(keyspaceName, functionName));
if (functions.size() > 1 && !argumentsSpeficied)
{
throw ire("'DROP FUNCTION %s' matches multiple function definitions; " +
"specify the argument types by issuing a statement like " +
"'DROP FUNCTION %s (type, type, ...)'. You can use cqlsh " +
"'DESCRIBE FUNCTION %s' command to find all overloads",
functionName, functionName, functionName);
}
arguments.stream()
.filter(raw -> !raw.isImplicitlyFrozen() && raw.isFrozen())
.findFirst()
.ifPresent(t -> { throw ire("Argument '%s' cannot be frozen; remove frozen<> modifier from '%s'", t, t); });
List<AbstractType<?>> argumentTypes = prepareArgumentTypes(keyspace.types);View on GitHub (pinned to 88fd0f6a0e)