apache/cassandra · error · ConstraintViolationException
Cannot parse constraint value from <term> for column '<colum
Error message
Cannot parse constraint value from <term> for column '<columnName>'
What it means
Thrown by ScalarColumnConstraint.validate during constraint definition when the constraint's term cannot be parsed into the column's return type via returnType.fromString. The CHECK expression is malformed for the column type, so the schema change is rejected.
Source
Thrown at src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java:140
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 + '\'');
}
}
@Override
public ConstraintType getConstraintType()
{
return ConstraintType.SCALAR;
}
@Override
public String toString()
{
return columnName + " " + relationType + " " + term;
}
@Override
public String name()
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Provide a term literal parseable by the column type (quote strings, use valid numeric/date literals).
- Use CQL native literals for timestamps (e.g. '2024-01-01 00:00:00+0000') rather than arbitrary formats.
- Verify the constraint targets the correct column and matches its type.
Example fix
// before: CHECK age > 'twenty' -- int column cannot parse term // after CHECK age > 20
Defensive patterns
Strategy: validation
Validate before calling
// Java: parse the term with the column type before DDL
// for an int column
Integer.parseInt("20"); // ok; parseInt("twenty") throws before you even issue ALTER Try / catch
catch (ConstraintViolationException | InvalidConstraintDefinitionException e) { log.error("cannot parse constraint term: {}", e.getMessage()); } Prevention
- Match literal style to column type (unquoted numbers, quoted strings/dates).
- Use canonical CQL timestamp literals for time columns.
- Never copy CHECK clauses across differently-typed columns without rewriting terms.
When it happens
Trigger: CREATE TABLE / ALTER TABLE with a CHECK whose term is not parseable by the column type, e.g. CHECK age = 'abc' on an int column, CHECK ts > 'not-a-date' on timestamp, or unquoted/unconvertible literals.
Common situations: String literals used for numeric or date columns; locale-dependent date strings; forgetting to quote string terms so the parser reads a bare identifier; copying constraints between columns of different types.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- category %s not found in %s
- GRANT operation is not supported by AllowAllAuthorizer
- REVOKE operation is not supported by AllowAllAuthorizer
- LIST PERMISSIONS operation is not supported by AllowAllAutho
- Invalidate CIDR permissions cache operation not supported by
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/d017b48aa6aeae9f.
Report an issue: GitHub.