apache/cassandra · error · InvalidConstraintDefinitionException

%s constraint of relation '%s' is not supported. Only these

Error message

%s constraint of relation '%s' is not supported. Only these are: %s

What it means

When defining a column constraint (CREATE TABLE ... CHECK), each constraint supports only a fixed set of relational operators returned by getSupportedOperators(). If the relationType used in the definition is not among them, checkSupportedOperators throws InvalidConstraintDefinitionException listing the allowed operators. This happens at schema-validation time (check), before the constraint is stored.

Source

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

    /**
     * Categorizes given constraints into two lists. The first list, the left one in Pair, contains all
     * constraints of implementation-specific {@link org.apache.cassandra.cql3.constraints.ColumnConstraint.ConstraintType}.
     * The second list, the right one in Pair, contains all constraints of such constraint type which do have "not equal" operator.
     *
     * @param constraints  constraints to categorize
     * @param functionName name of function
     * @return pair of categorized constraints
     */
    abstract Pair<List<CONSTRAINT_TYPE>, List<CONSTRAINT_TYPE>> categorizeConstraints(List<ColumnConstraint<?>> constraints, String functionName);

    abstract AbstractType<?> returnType(ColumnMetadata columnMetadata);

    private void checkSupportedOperators(List<CONSTRAINT_TYPE> allConstraints, String functionName)
    {
        for (CONSTRAINT_TYPE constraint : allConstraints)
        {
            if (!constraint.getSupportedOperators().contains(constraint.relationType()))
                throw new InvalidConstraintDefinitionException(format("%s constraint of relation '%s' is not supported. Only these are: %s",
                                                                      functionName,
                                                                      constraint.relationType(),
                                                                      constraint.getSupportedOperators()));
        }
    }

    /**
     * Checks if there are no duplicate constraints having same operator.
     *
     * @param columnMetadata      medata of a column
     * @param filteredConstraints pair of all constraints and all constraints having not-equal operator
     */
    private void checkNumberOfConstraints(ColumnMetadata columnMetadata, Pair<List<CONSTRAINT_TYPE>, List<CONSTRAINT_TYPE>> filteredConstraints)
    {
        List<? extends AbstractFunctionConstraint<CONSTRAINT_TYPE>> allConstraints = filteredConstraints.left;
        List<? extends AbstractFunctionConstraint<CONSTRAINT_TYPE>> notEqualConstraints = filteredConstraints.right;

        if ((allConstraints.size() - notEqualConstraints.size() > 2))

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Rewrite the constraint to use one of the operators listed in the exception message.
  2. Check the documentation for the specific constraint function's supported operators.
  3. If an operator seems legitimately needed, implement/extend getSupportedOperators() for that constraint type in a custom patch.

Example fix

// before
CREATE TABLE t (age int CHECK age = 18); // unsupported operator
// after
CREATE TABLE t (age int CHECK age >= 18);
Defensive patterns

Strategy: validation

Validate before calling

Set<Operator> supported = constraint.getSupportedOperators();
if (!supported.contains(relationType))
    throw new IllegalArgumentException("Operator " + relationType + " not supported; allowed: " + supported);

Try / catch

try {
    session.execute(schemaDdl);
} catch (InvalidRequestException e) {
    if (e.getMessage().contains("is not supported. Only these are:")) {
        log.error("Fix CHECK operator in DDL: {}", e.getMessage());
    } else throw e;
}

Prevention

When it happens

Trigger: CREATE TABLE / ALTER TABLE with a CHECK constraint using an unsupported operator for the constraint function, e.g. an equality-style relation on a constraint that only supports GT/LT comparisons.

Common situations: Typing the wrong operator in a CHECK clause; copying constraint syntax between constraint function families (e.g. length vs scalar constraints) with different operator sets; version differences in supported operators.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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