{"record":{"id":"d017b48aa6aeae9f","repo":"apache/cassandra","slug":"cannot-parse-constraint-value-from-term-for-colu","errorCode":null,"errorMessage":"Cannot parse constraint value from <term> for column '<columnName>'","messagePattern":"Cannot parse constraint value from <term> for column '<columnName>'","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java","lineNumber":140,"sourceCode":"        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        }\n    }\n\n    @Override\n    public ConstraintType getConstraintType()\n    {\n        return ConstraintType.SCALAR;\n    }\n\n    @Override\n    public String toString()\n    {\n        return columnName + \" \" + relationType + \" \" + term;\n    }\n\n    @Override\n    public String name()\n    {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/ScalarColumnConstraint.java#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: CHECK age > 'twenty' -- int column cannot parse term\n// after\nCHECK age > 20","handlingStrategy":"validation","validationCode":"// Java: parse the term with the column type before DDL\n// for an int column\nInteger.parseInt(\"20\"); // ok; parseInt(\"twenty\") throws before you even issue ALTER","typeGuard":null,"tryCatchPattern":"catch (ConstraintViolationException | InvalidConstraintDefinitionException e) { log.error(\"cannot parse constraint term: {}\", e.getMessage()); }","preventionTips":["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."],"tags":["cassandra","cql","constraint-definition","parse-error"],"backgroundTag":"invalid-argument-format","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"}