{"record":{"id":"6c80636f45aeb47d","repo":"apache/cassandra","slug":"column-value-does-not-satisfy-value-constraint-for-6c8063","errorCode":null,"errorMessage":"Column value does not satisfy value constraint for column '<columnName>'. It should be <columnName> <relationType> <term>","messagePattern":"Column value does not satisfy value constraint for column '<columnName>'\\. It should be <columnName> <relationType> <term>","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java","lineNumber":123,"sourceCode":"    }\n\n    @Override\n    public List<Operator> getSupportedOperators()\n    {\n        return SUPPORTED_OPERATORS;\n    }\n\n    @Override\n    public List<AbstractType<?>> getSupportedTypes()\n    {\n        return SUPPORTED_TYPES;\n    }\n\n    @Override\n    protected void internalEvaluate(AbstractType<?> valueType, ByteBuffer columnValue)\n    {\n        if (!relationType.isSatisfiedBy(valueType, columnValue, value))\n            throw new ConstraintViolationException(\"Column value does not satisfy value constraint for column '\" + columnName + \"'. \"\n                                                   + \"It should be \" + columnName + \" \" + relationType + \" \" + term);\n    }\n\n    @Override\n    public void validate(ColumnMetadata columnMetadata) throws InvalidConstraintDefinitionException\n    {\n        returnType = columnMetadata.type;\n\n        validateTypes(columnMetadata);\n\n        try\n        {\n            value = returnType.fromString(ParseUtils.unquote(term));\n        }\n        catch (Throwable t)\n        {\n            throw new ConstraintViolationException(\"Cannot parse constraint value from \" + term + \" for column '\" + columnName + '\\'');\n        }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java#L105-L141","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// constraint: CHECK age >= 0\n// before: INSERT INTO people (age) VALUES (-5); -- rejected\n// after\nINSERT INTO people (age) VALUES (0);","handlingStrategy":"validation","validationCode":"// Java: range-check before write, mirroring CHECK age >= 0\nif (age < 0) throw new IllegalArgumentException(\"age must be >= 0\");","typeGuard":null,"tryCatchPattern":"catch (ConstraintViolationException e) { log.warn(\"scalar constraint violated: {}\", e.getMessage()); }","preventionTips":["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."],"tags":["cassandra","cql","constraint-violation","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}