apache/cassandra · error · InvalidRequestException
Invalid operation (%s) for non-numeric and non-text type %s
Error message
Invalid operation (%s) for non-numeric and non-text type %s
What it means
Cassandra throws this during preparation when an add/increment operation (col = col + value) targets a column that is neither a numeric type nor a string type, in a context where existing state is readable (regular, non-counter table). Only numbers (with arithmetic semantics) and strings/blobs (concatenation) support the '+' operation.
Source
Thrown at src/java/org/apache/cassandra/cql3/Operation.java:342
{
private final Term.Raw value;
public Addition(Term.Raw value)
{
this.value = value;
}
public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException
{
if (!(receiver.type instanceof CollectionType))
{
if (receiver.type instanceof TupleType)
throw new InvalidRequestException(String.format("Invalid operation (%s) for tuple column %s", toString(receiver), receiver.name));
if (canReadExistingState)
{
if (!(receiver.type instanceof NumberType<?>) && !(receiver.type instanceof StringType))
throw new InvalidRequestException(String.format("Invalid operation (%s) for non-numeric and non-text type %s", toString(receiver), receiver.name));
}
else
{
if (!(receiver.type instanceof CounterColumnType))
throw new InvalidRequestException(String.format("Invalid operation (%s) for non counter column %s", toString(receiver), receiver.name));
}
return new Constants.Adder(receiver, value.prepare(metadata.keyspace, receiver));
}
else if (!(receiver.type.isMultiCell()))
throw new InvalidRequestException(String.format("Invalid operation (%s) for frozen collection column %s", toString(receiver), receiver.name));
switch (((CollectionType<?>)receiver.type).kind)
{
case LIST:
return new Lists.Appender(receiver, value.prepare(metadata.keyspace, receiver));
case SET:
return new Sets.Adder(receiver, value.prepare(metadata.keyspace, receiver));
case MAP:View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Change the target column to a numeric type (int, bigint, counter...) if incrementing is intended
- Use string/blob types if concatenation was intended
- Replace the operation with a full assignment of the desired new value
- Fix application query builders so '+' operations are only emitted for numeric/text columns
Example fix
// before (flag boolean) UPDATE users SET flag = flag + 1 WHERE id = 1; // after UPDATE users SET flag = true WHERE id = 1;
Defensive patterns
Strategy: validation
Validate before calling
AbstractType<?> t = tm.getColumn(col).getType();
if (!(t instanceof NumberType<?>) && !(t instanceof StringType))
throw new IllegalArgumentException(col + " does not support + operations"); Type guard
boolean supportsAdd(AbstractType<?> t) { return t instanceof NumberType<?> || t instanceof StringType; } Prevention
- Restrict '+' syntax generation to numeric and string columns
- Add type-aware validation in ORM/DAO layers before execution
- Cover non-numeric update paths with unit tests
When it happens
Trigger: 'UPDATE t SET mycol = mycol + <value>' where mycol is e.g. a boolean, timestamp-incompatible usage, uuid, inet, or any non-number/non-text type in a normal table (canReadExistingState=true).
Common situations: Assuming '+' works like concatenation on any type; trying to increment a uuid/inet/boolean column; ORM-generated increments applied to all columns.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Invalid operation (%s) for non-UDT column %s
- Invalid operation (%s) for non counter column %s
- category %s not found in %s
- GRANT operation is not supported by AllowAllAuthorizer
- REVOKE operation is not supported by AllowAllAuthorizer
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/e666e90bf6f2e643.
Report an issue: GitHub.