apache/cassandra · error · InvalidRequestException
Unsupported '!=' relation
Error message
Unsupported '!=' relation: %s
What it means
Relation.toRestriction rejects the != operator used with a token() relation: NEQ on token is not supported because it cannot be evaluated against the partitioner's ring during restriction conversion. InvalidRequestException at query preparation.
Solutions
- Remove the token(...) != value relation.
- Use token() with equality or range operators, or filter on partition key columns directly if ALLOW FILTERING semantics apply.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/java/org/apache/cassandra/cql3/Relation.java:199 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/1cba119fd637bf47.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/Relation.java:199
public boolean onToken()
{
return rawExpressions.kind() == ColumnsExpression.Kind.TOKEN;
}
/**
* Converts this <code>Relation</code> into a <code>Restriction</code>.
*
* @param table the table metadata
* @param boundNames the variables specification where to collect the bind variables
* @return the <code>Restriction</code> corresponding to this <code>Relation</code>
* @throws InvalidRequestException if this <code>Relation</code> is not valid
*/
public SingleRestriction toRestriction(TableMetadata table, VariableSpecifications boundNames, Object owner, boolean allowFiltering)
{
ColumnsExpression columnsExpression = rawExpressions.prepare(table);
if (operator == Operator.NEQ && columnsExpression.kind() == ColumnsExpression.Kind.TOKEN)
throw invalidRequest("Unsupported '!=' relation: %s", this);
// TODO support restrictions on list elements as we do in conditions, then we can probably move below validations
// to ElementExpression prepare/validateColumns
if (columnsExpression.isMapElementExpression())
{
ColumnMetadata column = columnsExpression.firstColumn();
AbstractType<?> baseType = column.type.unwrap();
checkFalse(baseType instanceof ListType, "Indexes on list entries (%s[index] = value) are not supported.", column.name);
checkTrue(baseType instanceof MapType, "Column %s cannot be used as a map", column.name);
if (column.isClusteringColumn() && baseType.isCollection() && !column.type.isMultiCell())
throw invalidRequest(FROZEN_MAP_ENTRY_PREDICATES_NOT_SUPPORTED, column.name);
columnsExpression.collectMarkerSpecification(boundNames, owner);
}
operator.validateFor(columnsExpression);
View on GitHub (pinned to 88fd0f6a0e)