{"record":{"id":"e7e5ffc5d1cea505","repo":"apache/cassandra","slug":"there-are-duplicate-constraint-definitions-on-colu-e7e5ff","errorCode":null,"errorMessage":"There are duplicate constraint definitions on column '%s'.","messagePattern":"There are duplicate constraint definitions on column '(.+?)'\\.","errorType":"validation","errorClass":"InvalidConstraintDefinitionException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java","lineNumber":150,"sourceCode":"        if ((firstRelation == GT && secondRelation == GTE) ||\n            (firstRelation == GTE && secondRelation == GT) ||\n            (firstRelation == LT && secondRelation == LTE) ||\n            (firstRelation == LTE && secondRelation == LT) ||\n            (firstRelation == EQ || secondRelation == EQ))\n        {\n            throw new InvalidConstraintDefinitionException(format(\"Constraints combination of %s is not supported: %s %s %s, %s %s %s\",\n                                                                  constraintName,\n                                                                  columnMetadata.name,\n                                                                  firstRelation,\n                                                                  firstTerm,\n                                                                  columnMetadata.name,\n                                                                  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,","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java#L132-L168","documentation":"If two NEQ constraints on a column reference the exact same term, ensureSatisfiability flags them as duplicate constraint definitions and throws InvalidConstraintDefinitionException with the column name. This is the pairwise duplicate check complementing the bulk check in checkNumberOfConstraints.","triggerScenarios":"Two NEQ constraints on the same column whose term strings are equal, e.g. CHECK v != 'a' AND v != 'a'.","commonSituations":"Hand-written DDL with repeated clauses; schema tooling appending identical exclusions from two rule sources.","solutions":["Delete one of the duplicated NEQ constraints.","Deduplicate exclusion lists before generating DDL.","Compare existing table definition with the new DDL to avoid re-adding constraints."],"exampleFix":"// before\nCHECK v != 'a' AND v != 'a'\n// after\nCHECK v != 'a'","handlingStrategy":"validation","validationCode":"if (neqA.term().equals(neqB.term()))\n    throw new IllegalArgumentException(\"Duplicate NEQ constraint on column\");","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(schemaDdl);\n} catch (InvalidRequestException e) {\n    if (e.getMessage().endsWith(\"duplicate constraint definitions\")) {\n        log.error(\"Drop one of the identical NEQ constraints: {}\", e.getMessage());\n    } else throw e;\n}","preventionTips":["Compare new DDL with existing schema before applying","Use Set semantics when materializing exclusion rules"],"tags":["cassandra","cql","constraints","duplicate"],"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"}