apache/cassandra · error · InvalidRequestException
Invalid operation ( ) for non-numeric type
Error message
Invalid operation (%s) for non-numeric type %s
What it means
An arithmetic operation (e.g. `c = c + 1` via Constants.Adder/Substracter) was applied to a column whose type is neither numeric nor a collection, and the statement requires reading existing state. Cassandra validates the receiver column type at prepare time and rejects non-numeric targets.
Solutions
- Verify the column type with DESCRIBE TABLE; only numeric types support + / - arithmetic
- For counters, ensure the column is of counter type and the table is counter-only
- Use string-specific operations instead of arithmetic for text columns
- Migrate the column type if arithmetic semantics are actually needed
Example fix
// before: text column UPDATE t SET name = name + 1 WHERE k = 1; // after: numeric column UPDATE t SET count = count + 1 WHERE k = 1;
Defensive patterns
Strategy: validation
Validate before calling
// check schema first
Row r = session.execute("SELECT type FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?", ks, table, col).one();
boolean numeric = java.util.List.of("int","bigint","smallint","tinyint","varint","decimal","double","float","counter").contains(r.getString("type")); Try / catch
try { session.execute(update); } catch (InvalidQueryException e) { if (e.getMessage().contains("non-numeric type")) { /* use non-arithmetic update */ } else throw e; } Prevention
- Only use + / - arithmetic on numeric or counter columns
- Verify column types after any schema migration
- Never use arithmetic as string concatenation in CQL
When it happens
Trigger: `UPDATE t SET some_text_col = some_text_col + 1` or similar + / - operation on a text/boolean/blob/uuid column with canReadExistingState=true.
Common situations: Confusing string concatenation with arithmetic; schema drift where a column changed type after queries were written; applying counter-style increments to regular columns.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot assign value to of type
- Cannot assign value to of type
- Cannot cast value to type
- Cannot replace aggregate
- Cannot replace function
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/dbc430383c078a10.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/Operation.java:403
}
public static class Substraction implements RawUpdate
{
private final Term.Raw value;
public Substraction(Term.Raw value)
{
this.value = value;
}
public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException
{
if (!(receiver.type instanceof CollectionType))
{
if (canReadExistingState)
{
if (!(receiver.type instanceof NumberType<?>))
throw new InvalidRequestException(String.format("Invalid operation (%s) for non-numeric 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.Substracter(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.Discarder(receiver, value.prepare(metadata.keyspace, receiver));
case SET:
return new Sets.Discarder(receiver, value.prepare(metadata.keyspace, receiver));
case MAP:View on GitHub (pinned to 88fd0f6a0e)