apache/cassandra · error · InvalidRequestException
Unkown field in user type
Error message
Unkown field %s in user type %s
What it means
During ALTER TYPE ... RENAME, each requested old field name is looked up in the UDT; if it is not found and IF EXISTS was not given for the field, the rename fails with an InvalidRequest. Note the message contains a typo ('Unkown') and omits the keyspace argument in the format call relative to its message text — the real message will show only the field and type name plus an extra argument artifact.
Solutions
- Check the current fields with `DESCRIBE TYPE myks.addr` (or system_schema.types) and correct the old field name in the ALTER statement
- Use the IF EXISTS clause (`ALTER TYPE ... RENAME city TO town IF EXISTS`) to make a missing field a no-op
- Fix case sensitivity by quoting the identifier exactly as it was defined, e.g. RENAME "City" TO "Town"
Example fix
// before ALTER TYPE myks.addr RENAME city TO town; -- Unknown field city // after ALTER TYPE myks.addr RENAME town_old TO town; -- use actual field name, or: ALTER TYPE myks.addr RENAME city TO town IF EXISTS;
Defensive patterns
Strategy: validation
Validate before calling
// Verify the field exists before renaming:
Row typeRow = session.execute("SELECT field_names FROM system_schema.types WHERE keyspace_name='myks' AND type_name='addr'").one();
List<String> fields = typeRow.getList("field_names", String.class);
if (!fields.contains("city")) throw new IllegalArgumentException("field 'city' does not exist on addr"); Try / catch
try { session.execute(renameCql); }
catch (InvalidQueryException e) {
if (e.getMessage().contains("Unkown field")) { /* inspect DESCRIBE TYPE / system_schema.types and fix the name */ }
else throw e;
} Prevention
- Run DESCRIBE TYPE (or query system_schema.types) to confirm exact field names before renaming
- Remember UDT field identifiers are case-sensitive; quote identifiers to preserve case
- Use IF EXISTS on renames when scripts must be idempotent across environments
When it happens
Trigger: `ALTER TYPE myks.addr RENAME city TO town` where no field named `city` exists; misspelled field name; running against a keyspace/environment where the type has a different field set; case mismatch (CQL identifiers are case-sensitive in UDTs unless quoted).
Common situations: Typos in field names; quoting/case mistakes (city vs "City"); drift between environments (test vs prod schema); stale migration scripts after an earlier rename.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Duplicate field name
- Altering field types is no longer supported
- Cannot add new field
- Cannot add new field
- Cannot alter user type
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/a7bbc398cee95ecd.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/AlterTypeStatement.java:228
.map(uda -> uda.name().toString())
.collect(toList());
if (!dependentAggregates.isEmpty())
{
throw ire("Cannot alter user type %s as it is still used in INITCOND by aggregates %s",
userType.getCqlTypeName(),
join(", ", dependentAggregates));
}
List<FieldIdentifier> fieldNames = new ArrayList<>(userType.fieldNames());
renamedFields.forEach((oldName, newName) ->
{
int idx = userType.fieldPosition(oldName);
if (idx < 0)
{
if (!ifFieldExists)
throw ire("Unkown field %s in user type %s", oldName, userType.getCqlTypeName());
return;
}
fieldNames.set(idx, newName);
});
fieldNames.forEach(name ->
{
if (fieldNames.stream().filter(isEqual(name)).count() > 1)
throw ire("Duplicate field name %s in type %s", name, keyspaceName, userType.getCqlTypeName());
});
return new UserType(keyspaceName, userType.name, fieldNames, userType.fieldTypes(), true);
}
}
private static final class AlterField extends AlterTypeStatement
{
private AlterField(String keyspaceName, String typeName, boolean ifExists)View on GitHub (pinned to 88fd0f6a0e)