{"record":{"id":"ab1ff1564b8b2911","repo":"apache/cassandra","slug":"constraints-of-s-are-not-satisfiable-s-s-s","errorCode":null,"errorMessage":"Constraints of %s are not satisfiable: %s %s %s, %s %s %s","messagePattern":"Constraints of (.+?) are not satisfiable: (.+?) (.+?) (.+?), (.+?) (.+?) (.+?)","errorType":"validation","errorClass":"InvalidConstraintDefinitionException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java","lineNumber":162,"sourceCode":"                                                                  secondRelation,\n                                                                  secondTerm));\n        }\n        else if (firstRelation == NEQ && secondRelation == NEQ)\n        {\n            if (firstTerm.equals(secondTerm))\n                throw new InvalidConstraintDefinitionException(format(\"There are duplicate constraint definitions on column '%s'.\", columnMetadata.name));\n        }\n        else\n        {\n            AbstractType<?> returnType = returnType(columnMetadata);\n            ByteBuffer firstTermBuffer = returnType.fromString(ParseUtils.unquote(firstTerm));\n            ByteBuffer secondTermBuffer = returnType.fromString(ParseUtils.unquote(secondTerm));\n\n            boolean firstSatisfaction = firstRelation.isSatisfiedBy(returnType, secondTermBuffer, firstTermBuffer);\n            boolean secondSatisfaction = secondRelation.isSatisfiedBy(returnType, firstTermBuffer, secondTermBuffer);\n\n            if (!firstSatisfaction || !secondSatisfaction)\n                throw new InvalidConstraintDefinitionException(format(\"Constraints of %s are not satisfiable: %s %s %s, %s %s %s\",\n                                                                      constraintName,\n                                                                      columnMetadata.name,\n                                                                      firstRelation,\n                                                                      firstTerm,\n                                                                      columnMetadata.name,\n                                                                      secondRelation,\n                                                                      secondTerm));\n        }\n    }\n\n    public static final AbstractFunctionSatisfiabilityChecker<ScalarColumnConstraint> SCALAR_SATISFIABILITY_CHECKER = new AbstractFunctionSatisfiabilityChecker<>()\n    {\n        @Override\n        public Pair<List<ScalarColumnConstraint>, List<ScalarColumnConstraint>> categorizeConstraints(List<ColumnConstraint<?>> constraints, String functionName)\n        {\n            List<ScalarColumnConstraint> scalars = new LinkedList<>();\n            List<ScalarColumnConstraint> notEqualScalars = new LinkedList<>();\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java#L144-L180","documentation":"For a pair of ordering constraints on a column, ensureSatisfiability tests whether any value could satisfy both by evaluating each relation against the other's term. If either direction is unsatisfied (e.g. x > 10 AND x < 5), the constraints are unsatisfiable and InvalidConstraintDefinitionException is thrown listing the column, both relations, and terms.","triggerScenarios":"CREATE TABLE/ALTER TABLE with mutually contradictory bounds on a column, e.g. CHECK x > 10 AND x < 5, or bounds that exclude every possible value.","commonSituations":"Typos in bound values; copied constraints whose terms conflict after a column rename; automated rule merging producing inverted ranges.","solutions":["Correct the bound values so the range is non-empty (min < max).","Check the constraint terms against actual expected data values.","Compute the intended interval first, then write the constraints from it."],"exampleFix":"// before\nCREATE TABLE t (x int CHECK x > 10 AND x < 5);\n// after\nCREATE TABLE t (x int CHECK x > 10 AND x < 50);","handlingStrategy":"validation","validationCode":"// sanity-check bounds form a non-empty interval before emitting DDL\nif (!(minValue < maxValue))\n    throw new IllegalArgumentException(\"Unsatisfiable range: min=\" + minValue + \" max=\" + maxValue);","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(schemaDdl);\n} catch (InvalidRequestException e) {\n    if (e.getMessage().contains(\"are not satisfiable\")) {\n        log.error(\"Constraints contradict each other: {}\", e.getMessage());\n    } else throw e;\n}","preventionTips":["Define min/max from a single source of truth","Test CREATE TABLE DDL on a dev cluster first","Lint for inverted ranges in generated constraints"],"tags":["cassandra","cql","constraints","satisfiability"],"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"}