{"record":{"id":"dc939eada7068fbb","repo":"apache/cassandra","slug":"aggregate-s-doesn-t-exist","errorCode":null,"errorMessage":"Aggregate '%s' doesn't exist","messagePattern":"Aggregate '(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/DropAggregateStatement.java","lineNumber":92,"sourceCode":"    {\n        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n    }\n\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        String name =\n            argumentsSpeficied\n          ? format(\"%s.%s(%s)\", keyspaceName, aggregateName, join(\", \", transform(arguments, CQL3Type.Raw::toString)))\n          : format(\"%s.%s\", keyspaceName, aggregateName);\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(\"Aggregate '%s' doesn't exist\", name);\n        }\n\n        Collection<UserFunction> aggregates = keyspace.userFunctions.get(new FunctionName(keyspaceName, aggregateName));\n        if (aggregates.size() > 1 && !argumentsSpeficied)\n        {\n            throw ire(\"'DROP AGGREGATE %s' matches multiple function definitions; \" +\n                      \"specify the argument types by issuing a statement like \" +\n                      \"'DROP AGGREGATE %s (type, type, ...)'. You can use cqlsh \" +\n                      \"'DESCRIBE AGGREGATE %s' command to find all overloads\",\n                      aggregateName, aggregateName, aggregateName);\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":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/DropAggregateStatement.java#L74-L110","documentation":"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.","triggerScenarios":"DROP AGGREGATE ks.agg where ks does not exist, or where no aggregate named agg exists in ks, without IF EXISTS.","commonSituations":"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.","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"],"exampleFix":"// before\nDROP AGGREGATE sales.avg_sale;\n// after\nDROP AGGREGATE IF EXISTS sales.avg_sale;","handlingStrategy":"validation","validationCode":"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","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Use IF EXISTS for idempotent migration scripts","Check system_schema.aggregates before dropping"],"tags":["cql","drop-aggregate","not-found","uda"],"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"}