apache/cassandra · error · InvalidRequestException
Aggregate ' ' doesn't exist
Error message
Aggregate '%s' doesn't exist
What it means
DROP AGGREGATE failed because no aggregate (UDA) with the given name exists in the target keyspace (or the keyspace itself does not exist) and IF EXISTS was not specified. apply() validates existence against current schema before mutating it.
Solutions
- Add IF EXISTS: DROP AGGREGATE IF EXISTS ks.agg
- Verify the exact name with SELECT aggregate_name FROM system_schema.aggregates WHERE keyspace_name = 'ks';
- Create the aggregate first if the drop was premature
Example fix
// before DROP AGGREGATE sales.avg_sale; // after DROP AGGREGATE IF EXISTS sales.avg_sale;
Defensive patterns
Strategy: validation
Validate before calling
const rows = await session.execute("SELECT aggregate_name FROM system_schema.aggregates WHERE keyspace_name=? AND aggregate_name=?", [ks, name]); if (rows.rowLength === 0) return; // skip drop Try / catch
try { session.execute(`DROP AGGREGATE 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 migration scripts
- Check system_schema.aggregates before dropping
When it happens
Trigger: DROP AGGREGATE ks.agg where ks does not exist, or where no aggregate named agg exists in ks, without IF EXISTS.
Common situations: Typo in aggregate or keyspace name; aggregate was already dropped; dropping against a cluster where the UDA was never created; session keyspace differs from the one assumed.
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
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- 'DROP AGGREGATE ' matches multiple function definitions…
- Cannot alter user type
- Function ' ' doesn't exist
- Function ' ' is still referenced by aggregates
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/dc939eada7068fbb.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/DropAggregateStatement.java:92
{
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
}
public Keyspaces apply(ClusterMetadata metadata)
{
String name =
argumentsSpeficied
? format("%s.%s(%s)", keyspaceName, aggregateName, join(", ", transform(arguments, CQL3Type.Raw::toString)))
: format("%s.%s", keyspaceName, aggregateName);
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
if (null == keyspace)
{
if (ifExists)
return schema;
throw ire("Aggregate '%s' doesn't exist", name);
}
Collection<UserFunction> aggregates = keyspace.userFunctions.get(new FunctionName(keyspaceName, aggregateName));
if (aggregates.size() > 1 && !argumentsSpeficied)
{
throw ire("'DROP AGGREGATE %s' matches multiple function definitions; " +
"specify the argument types by issuing a statement like " +
"'DROP AGGREGATE %s (type, type, ...)'. You can use cqlsh " +
"'DESCRIBE AGGREGATE %s' command to find all overloads",
aggregateName, aggregateName, aggregateName);
}
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)