{"record":{"id":"6bfa812ba1911025","repo":"apache/cassandra","slug":"drop-aggregate-s-matches-multiple-function-defi","errorCode":null,"errorMessage":"'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","messagePattern":"'DROP AGGREGATE (.+?)' matches multiple function definitions; specify the argument types by issuing a statement like 'DROP AGGREGATE (.+?) \\(type, type, \\.\\.\\.\\)'\\. You can use cqlsh 'DESCRIBE AGGREGATE (.+?)' command to find all overloads","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/DropAggregateStatement.java","lineNumber":98,"sourceCode":"        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);\n\n        Predicate<UserFunction> filter = UserFunctions.Filter.UDA;\n        if (argumentsSpeficied)\n            filter = filter.and(f -> f.typesMatch(argumentTypes));\n\n        UserFunction aggregate = aggregates.stream().filter(filter).findAny().orElse(null);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/DropAggregateStatement.java#L80-L116","documentation":"The keyspace contains multiple overloads of the aggregate name, and the DROP AGGREGATE statement did not specify argument types, so the target is ambiguous. Cassandra refuses to guess which overload to drop.","triggerScenarios":"DROP AGGREGATE agg (no parenthesized type list) when two or more UDAs named agg with different signatures exist in the keyspace.","commonSituations":"Overloaded aggregates created with different argument types over time; migration scripts that drop by name only; cqlsh DESCRIBE not consulted before dropping.","solutions":["Drop with explicit argument types: DROP AGGREGATE ks.agg (type1, type2);","Run 'DESCRIBE AGGREGATE ks.agg' in cqlsh to list all overloads and their signatures","Add IF EXISTS if a matching-signature drop is optional"],"exampleFix":"// before\nDROP AGGREGATE sales.avg_sale;\n// after\nDROP AGGREGATE sales.avg_sale (int);","handlingStrategy":"validation","validationCode":"const rows = await session.execute(\"SELECT argument_types, count(*) FROM system_schema.aggregates WHERE keyspace_name=? AND aggregate_name=? GROUP BY argument_types\", [ks, name]); if (rows.rowLength > 1) throw new Error('Ambiguous: specify argument types');","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (e) { if (e instanceof InvalidQueryError && /matches multiple function definitions/.test(e.message)) { /* re-issue with explicit (type, ...) list */ } else throw e; }","preventionTips":["Always include the argument type list in DROP AGGREGATE for overloaded aggregates","Run DESCRIBE AGGREGATE to enumerate overloads first"],"tags":["cql","drop-aggregate","ambiguous","overload","uda"],"backgroundTag":"ambiguous-reference","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"}