apache/cassandra · error · InvalidRequestException
Duplicate field name
Error message
Duplicate field name '%s' in type '%s'
What it means
CreateTypeStatement.apply validation: the same field name appears more than once in the UDT's field list (detected via a HashSet of FieldIdentifier); duplicate field names are not permitted in a user-defined type.
Solutions
- Rename or remove duplicate fields so each field name in the type is unique.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java:107 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/05f2ef3ad80b829a.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java:107
{
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
if (null == keyspace)
throw ire("Keyspace '%s' doesn't exist", keyspaceName);
UserType existingType = keyspace.types.getNullable(bytes(typeName));
if (null != existingType)
{
if (ifNotExists)
return schema;
throw ire("A user type with name '%s' already exists", typeName);
}
Set<FieldIdentifier> usedNames = new HashSet<>();
for (FieldIdentifier name : fieldNames)
if (!usedNames.add(name))
throw ire("Duplicate field name '%s' in type '%s'", name, typeName);
for (CQL3Type.Raw type : rawFieldTypes)
{
if (type.isCounter())
throw ire("A user type cannot contain counters");
if (type.isUDT() && !type.isFrozen())
throw ire("A user type cannot contain non-frozen UDTs");
}
List<AbstractType<?>> fieldTypes =
rawFieldTypes.stream()
.map(t -> t.prepare(keyspaceName, keyspace.types).getType())
.collect(toList());
UserType udt = new UserType(keyspaceName, bytes(typeName), fieldNames, fieldTypes, true);
return schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.types.with(udt)));
}View on GitHub (pinned to 88fd0f6a0e)