apache/cassandra · error · InvalidConstraintDefinitionException

There are duplicate constraint definitions on column '%s'.

Error message

There are duplicate constraint definitions on column '%s'.

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java:150

        if ((firstRelation == GT && secondRelation == GTE) ||
            (firstRelation == GTE && secondRelation == GT) ||
            (firstRelation == LT && secondRelation == LTE) ||
            (firstRelation == LTE && secondRelation == LT) ||
            (firstRelation == EQ || secondRelation == EQ))
        {
            throw new InvalidConstraintDefinitionException(format("Constraints combination of %s is not supported: %s %s %s, %s %s %s",
                                                                  constraintName,
                                                                  columnMetadata.name,
                                                                  firstRelation,
                                                                  firstTerm,
                                                                  columnMetadata.name,
                                                                  secondRelation,
                                                                  secondTerm));
        }
        else if (firstRelation == NEQ && secondRelation == NEQ)
        {
            if (firstTerm.equals(secondTerm))
                throw new InvalidConstraintDefinitionException(format("There are duplicate constraint definitions on column '%s'.", columnMetadata.name));
        }
        else
        {
            AbstractType<?> returnType = returnType(columnMetadata);
            ByteBuffer firstTermBuffer = returnType.fromString(ParseUtils.unquote(firstTerm));
            ByteBuffer secondTermBuffer = returnType.fromString(ParseUtils.unquote(secondTerm));

            boolean firstSatisfaction = firstRelation.isSatisfiedBy(returnType, secondTermBuffer, firstTermBuffer);
            boolean secondSatisfaction = secondRelation.isSatisfiedBy(returnType, firstTermBuffer, secondTermBuffer);

            if (!firstSatisfaction || !secondSatisfaction)
                throw new InvalidConstraintDefinitionException(format("Constraints of %s are not satisfiable: %s %s %s, %s %s %s",
                                                                      constraintName,
                                                                      columnMetadata.name,
                                                                      firstRelation,
                                                                      firstTerm,
                                                                      columnMetadata.name,
                                                                      secondRelation,

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Delete one of the duplicated NEQ constraints.
  2. Deduplicate exclusion lists before generating DDL.
  3. Compare existing table definition with the new DDL to avoid re-adding constraints.

Example fix

// before
CHECK v != 'a' AND v != 'a'
// after
CHECK v != 'a'
Defensive patterns

Strategy: validation

Validate before calling

if (neqA.term().equals(neqB.term()))
    throw new IllegalArgumentException("Duplicate NEQ constraint on column");

Try / catch

try {
    session.execute(schemaDdl);
} catch (InvalidRequestException e) {
    if (e.getMessage().endsWith("duplicate constraint definitions")) {
        log.error("Drop one of the identical NEQ constraints: {}", e.getMessage());
    } else throw e;
}

Prevention

When it happens

Trigger: Two NEQ constraints on the same column whose term strings are equal, e.g. CHECK v != 'a' AND v != 'a'.

Common situations: Hand-written DDL with repeated clauses; schema tooling appending identical exclusions from two rule sources.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e7e5ffc5d1cea505. Report an issue: GitHub.