apache/cassandra · error · ConstraintViolationException
Column value does not satisfy value constraint for column '<
Error message
Column value does not satisfy value constraint for column '<columnName>'. It should be <columnName> <relationType> <term>
What it means
Thrown by ScalarColumnConstraint.internalEvaluate when a column value fails a scalar CHECK constraint (e.g. CHECK age > 0). The value is compared with the constraint's relationType against the parsed term using the column's type, and a violation rejects the write with ConstraintViolationException.
Source
Thrown at src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java:123
}
@Override
public List<Operator> getSupportedOperators()
{
return SUPPORTED_OPERATORS;
}
@Override
public List<AbstractType<?>> getSupportedTypes()
{
return SUPPORTED_TYPES;
}
@Override
protected void internalEvaluate(AbstractType<?> valueType, ByteBuffer columnValue)
{
if (!relationType.isSatisfiedBy(valueType, columnValue, value))
throw new ConstraintViolationException("Column value does not satisfy value constraint for column '" + columnName + "'. "
+ "It should be " + columnName + " " + relationType + " " + term);
}
@Override
public void validate(ColumnMetadata columnMetadata) throws InvalidConstraintDefinitionException
{
returnType = columnMetadata.type;
validateTypes(columnMetadata);
try
{
value = returnType.fromString(ParseUtils.unquote(term));
}
catch (Throwable t)
{
throw new ConstraintViolationException("Cannot parse constraint value from " + term + " for column '" + columnName + '\'');
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Write a value that satisfies the declared comparison for that column.
- ALTER the table to adjust the constraint bounds if the rule is too strict.
- Clamp or validate the value in application code before the write.
Example fix
// constraint: CHECK age >= 0 // before: INSERT INTO people (age) VALUES (-5); -- rejected // after INSERT INTO people (age) VALUES (0);
Defensive patterns
Strategy: validation
Validate before calling
// Java: range-check before write, mirroring CHECK age >= 0
if (age < 0) throw new IllegalArgumentException("age must be >= 0"); Try / catch
catch (ConstraintViolationException e) { log.warn("scalar constraint violated: {}", e.getMessage()); } Prevention
- Extract constraint bounds into app config so both layers agree.
- Validate computed/default values before insert.
- Use cqlsh DESCRIBE to audit constraints on hot tables.
When it happens
Trigger: INSERT/UPDATE of a column with a scalar CHECK constraint where the value does not satisfy the comparison (e.g. CHECK price < 1000 but 5000 is written; CHECK score >= 0 but -1 is written).
Common situations: Range constraints on numeric/timestamp columns violated by default values, negative results of upstream computation, unit mismatches (seconds vs milliseconds), or NULL-derived sentinel values.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Column value does not satisfy value constraint for column '<
- REVOKE operation is not supported by AllowAllAuthorizer
- Key may not be empty
- Key length of %d is longer than maximum of %d
- Value does not match regular expression %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/6c80636f45aeb47d.
Report an issue: GitHub.