apache/cassandra · error · InvalidRequestException
Duplicate argument names for given function
Error message
Duplicate argument names for given function %s with argument names %s
What it means
CREATE FUNCTION validation rejects a function whose argument names contain duplicates. Cassandra requires each argument of a user-defined function to have a unique identifier so arguments can be referenced unambiguously (e.g. in language bodies and state functions). The check compares the size of the argument-name set against the list size in CreateFunctionStatement.apply.
Solutions
- Rename the duplicated argument so every argument name in the signature is unique
- Review the full argument list in the CREATE FUNCTION statement for accidental repeats
- If DDL is generated, fix the generator to enforce unique parameter names
Example fix
// before CREATE FUNCTION ks.f(a int, a text) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return 0;'; // after CREATE FUNCTION ks.f(a int, b text) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return 0;';
Defensive patterns
Strategy: validation
Validate before calling
Set<String> names = new HashSet<>(argumentNames);
if (names.size() != argumentNames.size()) throw new IllegalArgumentException("Duplicate argument names: " + argumentNames); Type guard
boolean hasUniqueArgNames(List<String> names) { return new HashSet<>(names).size() == names.size(); } Try / catch
try { session.execute(createFunctionStmt); } catch (InvalidRequestException e) { if (e.getMessage().startsWith("Duplicate argument names")) { /* fix signature and retry */ } else throw e; } Prevention
- Enforce unique parameter names in any DDL generator
- Review function signatures after copy-paste edits
- Add CI linting for CQL function definitions
When it happens
Trigger: Executing CREATE [OR REPLACE] FUNCTION with two arguments sharing the same declared name, e.g. CREATE FUNCTION f(a int, a text).
Common situations: Copy-pasted function signatures where a parameter name was forgotten to be renamed; generated DDL scripts producing duplicated parameter names; typos that coincidentally match an existing parameter.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- Return type ' ' cannot be frozen; remove frozen<> modifier…
- Accord transactions are disabled on table (table is being…
- Aggregate name ' ' is invalid
- Argument ' ' cannot be frozen; remove frozen<> modifier from
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/a7baf8374f593cd6.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateFunctionStatement.java:106
@Override
public boolean compatibleWith(ClusterMetadata metadata)
{
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
}
// TODO: replace affected aggregates !!
public Keyspaces apply(ClusterMetadata metadata)
{
if (ifNotExists && orReplace)
throw ire("Cannot use both 'OR REPLACE' and 'IF NOT EXISTS' directives");
UDFunction.assertUdfsEnabled(language);
if (!FunctionName.isNameValid(functionName))
throw ire("Function name '%s' is invalid", functionName);
if (new HashSet<>(argumentNames).size() != argumentNames.size())
throw ire("Duplicate argument names for given function %s with argument names %s", functionName, argumentNames);
rawArgumentTypes.stream()
.filter(raw -> !raw.isImplicitlyFrozen() && raw.isFrozen())
.findFirst()
.ifPresent(t -> { throw ire("Argument '%s' cannot be frozen; remove frozen<> modifier from '%s'", t, t); });
if (!rawReturnType.isImplicitlyFrozen() && rawReturnType.isFrozen())
throw ire("Return type '%s' cannot be frozen; remove frozen<> modifier from '%s'", rawReturnType, rawReturnType);
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
if (null == keyspace)
throw ire("Keyspace '%s' doesn't exist", keyspaceName);
List<AbstractType<?>> argumentTypes =
rawArgumentTypes.stream()
.map(t -> t.prepare(keyspaceName, keyspace.types).getType().udfType())
.collect(toList());View on GitHub (pinned to 88fd0f6a0e)