{"record":{"id":"2ea2da3d29cd7fd4","repo":"apache/cassandra","slug":"slice-restrictions-are-not-supported-on-duration-c","errorCode":null,"errorMessage":"Slice restrictions are not supported on duration columns","messagePattern":"Slice restrictions are not supported on duration columns","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operator.java","lineNumber":992,"sourceCode":"    public void validateFor(ColumnsExpression expression)\n    {\n        // this method is used only in restrictions, not in conditions where different rules apply for now\n        if (!isSupportedByRestrictionsOn(expression))\n            throw invalidRequest(\"%s cannot be used with %s relations\", this, expression);\n\n        switch (expression.kind())\n        {\n            case SINGLE_COLUMN:\n                ColumnMetadata firstColumn = expression.firstColumn();\n                AbstractType<?> columnType = firstColumn.type;\n                if (isSlice() && this != Operator.NEQ)\n                {\n                    if (columnType.referencesDuration())\n                    {\n                        checkFalse(columnType.isCollection(), \"Slice restrictions are not supported on collections containing durations\");\n                        checkFalse(columnType.isTuple(), \"Slice restrictions are not supported on tuples containing durations\");\n                        checkFalse(columnType.isUDT(), \"Slice restrictions are not supported on UDTs containing durations\");\n                        throw invalidRequest(\"Slice restrictions are not supported on duration columns\");\n                    }\n                }\n                else\n                {\n                    checkFalse(appliesToMapKeys() && !(columnType instanceof MapType), \"Cannot use %s on non-map column %s\", this, firstColumn.name);\n                    checkFalse(appliesToCollectionElements() && !columnType.isCollection(), \"Cannot use %s on non-collection column %s\", this, firstColumn.name);\n                }\n\n            // intentional fallthrough - missing break statement\n            case ELEMENT:\n                ColumnMetadata column = expression.firstColumn();\n                AbstractType<?> type = column.type;\n                if (type.isMultiCell())\n                {\n                    // Non-frozen UDTs don't support any operator\n                    checkFalse(type.isUDT(),\n                               \"Non-frozen UDT column '%s' (%s) cannot be restricted by any relation\",\n                               column.name,","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operator.java#L974-L1010","documentation":"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.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/Operator.java:992 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use equality (=, !=) on duration columns instead of range operators.","Range queries require storing comparable components (e.g. seconds as bigint) in a separate column."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}