apache/cassandra · error · InvalidRequestException
%s cannot be restricted by more than one relation if it incl
Error message
%s cannot be restricted by more than one relation if it includes an Equal
What it means
When a column is restricted by more than one relation, checkOperator() rejects the merge if any of them is an equality (or the column is restricted at token level). Multiple relations may only refine an inequality; an EQ plus anything else is contradictory or redundant, so it fails validation.
Source
Thrown at src/java/org/apache/cassandra/cql3/restrictions/MergedRestriction.java:180
throw invalidRequest("More than one restriction was found for the start bound on %s",
toCQLString(getColumnsInCommons(restriction, other)));
}
if ((restriction.operator() == Operator.LT || restriction.operator() == Operator.LTE || restriction.operator() == Operator.BETWEEN) &&
(other.operator() == Operator.LT || other.operator() == Operator.LTE || other.operator() == Operator.BETWEEN))
{
throw invalidRequest("More than one restriction was found for the end bound on %s",
toCQLString(getColumnsInCommons(restriction, other)));
}
}
}
private static void checkOperator(SimpleRestriction restriction)
{
if (restriction.isColumnLevel() || restriction.isOnToken())
{
if (restriction.isEQ())
throw invalidRequest("%s cannot be restricted by more than one relation if it includes an Equal",
toCQLString(restriction.columns()));
if (restriction.isIN())
throw invalidRequest("%s cannot be restricted by more than one relation if it includes a IN",
toCQLString(restriction.columns()));
if (restriction.isANN())
throw invalidRequest("%s cannot be restricted by more than one relation in an ANN ordering",
toCQLString(restriction.columns()));
}
}
/**
* Returns the columns that are specified within the 2 {@code Restrictions}.
*
* @param restriction the first restriction
* @param other the other restriction
* @return the columns that are specified within the 2 {@code Restrictions}.
*/View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Remove the redundant/contradictory duplicate restriction
- Use IN for multiple values: WHERE pk IN (1, 2) instead of pk = 1 AND pk = 2
- Deduplicate predicates by column name in query-building code
Example fix
// before SELECT * FROM users WHERE id = 1 AND id = 2; // after SELECT * FROM users WHERE id IN (1, 2);
Defensive patterns
Strategy: validation
Validate before calling
const eqCount = predicates.filter(p => p.column === col && p.op === '=').length;
if (eqCount > 1) throw new Error('Column ' + col + ' restricted by more than one relation including EQ'); Prevention
- Restrict each column exactly once
- Use IN instead of repeated EQ predicates
- Deduplicate predicates by column in query-assembly code
When it happens
Trigger: Queries like WHERE pk = 1 AND pk = 2, or a column appearing in both an EQ and a token/INEQ restriction merged through MergedRestriction.validate().
Common situations: Dynamically generated WHERE clauses where the same column is added twice (once as filter, once as key lookup); duplicated query parameters in an application layer.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- %s cannot be restricted by more than one relation if it incl
- PRIMARY KEY column "%s" cannot be restricted (preceding colu
- Column "%s" cannot be restricted by two inequalities not sta
- More than one restriction was found for the start bound on %
- More than one restriction was found for the end bound on %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/730a6c5dc14ea086.
Report an issue: GitHub.