{"record":{"id":"08fa64d8bc4d4175","repo":"apache/cassandra","slug":"invalid-operation-s-for-tuple-column-s","errorCode":null,"errorMessage":"Invalid operation (%s) for tuple column %s","messagePattern":"Invalid operation \\((.+?)\\) for tuple column (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operation.java","lineNumber":337,"sourceCode":"                return !(other instanceof SetValue);\n        }\n    }\n\n    public static class Addition implements RawUpdate\n    {\n        private final Term.Raw value;\n\n        public Addition(Term.Raw value)\n        {\n            this.value = value;\n        }\n\n        public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException\n        {\n            if (!(receiver.type instanceof CollectionType))\n            {\n                if (receiver.type instanceof TupleType)\n                    throw new InvalidRequestException(String.format(\"Invalid operation (%s) for tuple column %s\", toString(receiver), receiver.name));\n\n                if (canReadExistingState)\n                {\n                    if (!(receiver.type instanceof NumberType<?>) && !(receiver.type instanceof StringType))\n                        throw new InvalidRequestException(String.format(\"Invalid operation (%s) for non-numeric and non-text type %s\", toString(receiver), receiver.name));\n                }\n                else\n                {\n                    if (!(receiver.type instanceof CounterColumnType))\n                        throw new InvalidRequestException(String.format(\"Invalid operation (%s) for non counter column %s\", toString(receiver), receiver.name));\n                }\n                return new Constants.Adder(receiver, value.prepare(metadata.keyspace, receiver));\n            }\n            else if (!(receiver.type.isMultiCell()))\n                throw new InvalidRequestException(String.format(\"Invalid operation (%s) for frozen collection column %s\", toString(receiver), receiver.name));\n\n            switch (((CollectionType<?>)receiver.type).kind)\n            {","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operation.java#L319-L355","documentation":"Cassandra throws this during preparation when a counter-style arithmetic operation (col = col + <n>, i.e. Constants.Adder) targets a tuple column. Tuples are neither collections (multi-cell) nor numeric/text scalars eligible for addition, so the adder is rejected.","triggerScenarios":"Using increment syntax like 'UPDATE t SET mytuple = mytuple + something' or any +/- operation on a tuple-typed column; the prepare() path for Adder hits the TupleType check first.","commonSituations":"Confusing tuple columns with counters or collections; generic update code that appends '+' operations to any column; schema migrated from a numeric column to a tuple.","solutions":["Replace the whole tuple value with a plain assignment: SET mytuple = (v1, v2)","Remove the arithmetic/append operation for tuple columns in application code","If incremental semantics are needed, split the tuple into separate scalar/counter columns"],"exampleFix":"// before (loc tuple<int,int>)\nUPDATE points SET loc = loc + (1,1) WHERE id = 1;\n// after\nUPDATE points SET loc = (2,3) WHERE id = 1;  -- assign a full new tuple","handlingStrategy":"validation","validationCode":"AbstractType<?> t = tm.getColumn(col).getType();\nif (t instanceof TupleType) throw new IllegalArgumentException(col + \" is a tuple; assign full values, no +/- operations\");","typeGuard":"boolean isTuple(AbstractType<?> t) { return t instanceof TupleType; }","tryCatchPattern":null,"preventionTips":["Only apply arithmetic ops to numeric/counter columns","Keep a registry of column types in the query builder","Review generic 'append' helpers for type restrictions"],"tags":["cql","cassandra","tuple"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}