apache/cassandra · error · InvalidRequestException

Slice restrictions are not supported on duration columns

Error message

Slice restrictions are not supported on duration columns

What it means

Operator.validateFor rejects slice restrictions (<, <=, >, >=) applied to a column of type duration; durations have no total order usable for range filtering. Raised as InvalidRequestException during restriction preparation.

Solutions

  1. Use equality (=, !=) on duration columns instead of range operators.
  2. Range queries require storing comparable components (e.g. seconds as bigint) in a separate column.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/java/org/apache/cassandra/cql3/Operator.java:992 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/Operator.java:992

    public void validateFor(ColumnsExpression expression)
    {
        // this method is used only in restrictions, not in conditions where different rules apply for now
        if (!isSupportedByRestrictionsOn(expression))
            throw invalidRequest("%s cannot be used with %s relations", this, expression);

        switch (expression.kind())
        {
            case SINGLE_COLUMN:
                ColumnMetadata firstColumn = expression.firstColumn();
                AbstractType<?> columnType = firstColumn.type;
                if (isSlice() && this != Operator.NEQ)
                {
                    if (columnType.referencesDuration())
                    {
                        checkFalse(columnType.isCollection(), "Slice restrictions are not supported on collections containing durations");
                        checkFalse(columnType.isTuple(), "Slice restrictions are not supported on tuples containing durations");
                        checkFalse(columnType.isUDT(), "Slice restrictions are not supported on UDTs containing durations");
                        throw invalidRequest("Slice restrictions are not supported on duration columns");
                    }
                }
                else
                {
                    checkFalse(appliesToMapKeys() && !(columnType instanceof MapType), "Cannot use %s on non-map column %s", this, firstColumn.name);
                    checkFalse(appliesToCollectionElements() && !columnType.isCollection(), "Cannot use %s on non-collection column %s", this, firstColumn.name);
                }

            // intentional fallthrough - missing break statement
            case ELEMENT:
                ColumnMetadata column = expression.firstColumn();
                AbstractType<?> type = column.type;
                if (type.isMultiCell())
                {
                    // Non-frozen UDTs don't support any operator
                    checkFalse(type.isUDT(),
                               "Non-frozen UDT column '%s' (%s) cannot be restricted by any relation",
                               column.name,

View on GitHub (pinned to 88fd0f6a0e)