{"record":{"id":"5b1c1ca4a960c34d","repo":"apache/cassandra","slug":"invalid-restrictions-on-clustering-columns-since-t","errorCode":null,"errorMessage":"Invalid restrictions on clustering columns since the %s statement modifies only static columns","messagePattern":"Invalid restrictions on clustering columns since the (.+?) statement modifies only static columns","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java","lineNumber":292,"sourceCode":"        // Some but not all of the partition key columns have been specified;\n        // hence we need turn these restrictions into a row filter.\n        if (usesSecondaryIndexing || partitionKeyRestrictions.needFiltering())\n            filterRestrictions.add(partitionKeyRestrictions);\n\n        if (selectsOnlyStaticColumns && hasClusteringColumnsRestrictions())\n        {\n            // If the only updated/deleted columns are static, then we don't need clustering columns.\n            // And in fact, unless it is an INSERT, we reject if clustering colums are provided as that\n            // suggest something unintended. For instance, given:\n            //   CREATE TABLE t (k int, v int, s int static, PRIMARY KEY (k, v))\n            // it can make sense to do:\n            //   INSERT INTO t(k, v, s) VALUES (0, 1, 2)\n            // but both\n            //   UPDATE t SET s = 3 WHERE k = 0 AND v = 1\n            //   DELETE v FROM t WHERE k = 0 AND v = 1\n            // sounds like you don't really understand what your are doing.\n            if (type.isDelete() || type.isUpdate())\n                throw invalidRequest(\"Invalid restrictions on clustering columns since the %s statement modifies only static columns\",\n                                     type);\n            if (type.isSelect())\n                throw invalidRequest(\"Cannot restrict clustering columns when selecting only static columns\");\n        }\n\n        processClusteringColumnsRestrictions(hasQueriableIndex,\n                                             selectsOnlyStaticColumns,\n                                             forView,\n                                             allowFiltering);\n\n        // Covers indexes on the first clustering column (among others).\n        if (isKeyRange && hasQueriableClusteringColumnIndex)\n            usesSecondaryIndexing = true;\n\n        if (usesSecondaryIndexing || clusteringColumnsRestrictions.needFiltering())\n            filterRestrictions.add(clusteringColumnsRestrictions);\n\n        // Even if usesSecondaryIndexing is false at this point, we'll still have to use one if","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java#L274-L310","documentation":"Thrown when an UPDATE or DELETE that modifies only static columns includes restrictions on clustering columns. Since a static-column write applies to the whole partition, clustering restrictions are semantically meaningless (they don't narrow which rows are modified), so Cassandra rejects them.","triggerScenarios":"`UPDATE t SET s=3 WHERE k=0 AND c=1` where s is static and c is clustering; `DELETE s FROM t WHERE k=0 AND c=1`; any statement whose modified columns are all static while the WHERE clause restricts clustering columns.","commonSituations":"Developers assuming static-column updates apply per-row; migration from a table where the column was not static; code-generation bugs that always append clustering predicates.","solutions":["Remove the clustering column restrictions and restrict only the partition key: `UPDATE t SET s=3 WHERE k=0`.","If per-clustering-row modification is intended, move the column out of static so it becomes a regular column.","If a per-row static 'view' is needed, split into two tables: one keyed for static data, one for clustering rows.","Use SELECT-only restriction or a DELETE of regular columns pattern if the intent was row deletion, not static modification."],"exampleFix":"// before\nUPDATE t SET s = 3 WHERE k = 0 AND c = 1; -- s is static\n// after\nUPDATE t SET s = 3 WHERE k = 0;","handlingStrategy":"validation","validationCode":"// strip clustering restrictions when only static columns are modified\nif (modifiesOnlyStaticColumns(stmt) && hasClusteringRestrictions(whereClause)) throw new IllegalArgumentException(\"static-column write cannot restrict clustering columns\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember static values are per-partition; write them with partition-key-only WHERE.","Avoid making columns static unless the write model is truly partition-wide.","Assert at query-construction time that modified columns match restriction scope."],"tags":["cql","invalid-request","static-columns","clustering"],"backgroundTag":"invalid-argument-value","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"}