{"record":{"id":"b88d3a5c9e8e7731","repo":"apache/cassandra","slug":"invalid-operation-s-for-non-udt-column-s","errorCode":null,"errorMessage":"Invalid operation (%s) for non-UDT column %s","messagePattern":"Invalid operation \\((.+?)\\) for non-UDT column (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operation.java","lineNumber":297,"sourceCode":"            return !(other instanceof SetValue);\n        }\n    }\n\n    public static class SetField implements RawUpdate\n    {\n        private final FieldIdentifier field;\n        private final Term.Raw value;\n\n        public SetField(FieldIdentifier field, Term.Raw value)\n        {\n            this.field = field;\n            this.value = value;\n        }\n\n        public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException\n        {\n            if (!receiver.type.isUDT())\n                throw new InvalidRequestException(String.format(\"Invalid operation (%s) for non-UDT column %s\", toString(receiver), receiver.name));\n            else if (!receiver.type.isMultiCell())\n                throw new InvalidRequestException(String.format(\"Invalid operation (%s) for frozen UDT column %s\", toString(receiver), receiver.name));\n\n            int fieldPosition = ((UserType) receiver.type).fieldPosition(field);\n            if (fieldPosition == -1)\n                throw new InvalidRequestException(String.format(\"UDT column %s does not have a field named %s\", receiver.name, field));\n\n            Term val = value.prepare(metadata.keyspace, UserTypes.fieldSpecOf(receiver, fieldPosition));\n            return new UserTypes.SetterByField(receiver, field, val);\n        }\n\n        protected String toString(ColumnSpecification column)\n        {\n            return String.format(\"%s.%s = %s\", column.name, field, value);\n        }\n\n        public boolean isCompatibleWith(RawUpdate other)\n        {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operation.java#L279-L315","documentation":"Cassandra throws this during preparation when a UDT field-update operation (udt.field = value) targets a column that is not a user-defined type. Only non-frozen UDT columns support per-field assignment; any other column type is rejected before field resolution.","triggerScenarios":"Executing 'UPDATE t SET mycol.fieldname = v WHERE ...' where mycol is not a UDT (scalar, collection, tuple); e.g. using field syntax on a tuple or text column.","commonSituations":"Column type confusion between tuple and UDT (both use dot-notation concepts); schema changed from UDT to another type; copy-pasted queries across tables.","solutions":["Confirm the column type with DESCRIBE TABLE; use plain assignment for non-UDT columns","If field-wise updates are wanted, change the column to a (non-frozen) UDT and migrate data","For tuples, replace the whole tuple value instead of assigning a field"],"exampleFix":"// before (address is tuple<text,text>)\nUPDATE users SET address.city = 'NYC' WHERE id = 1;\n// after\nUPDATE users SET address = ('NYC','10001') WHERE id = 1;  -- replace whole tuple","handlingStrategy":"validation","validationCode":"AbstractType<?> t = tm.getColumn(col).getType();\nif (!t.isUDT()) throw new IllegalArgumentException(col + \" is not a UDT; use plain assignment\");","typeGuard":"boolean isUdt(AbstractType<?> t) { return t.isUDT(); }","tryCatchPattern":null,"preventionTips":["Check system_schema.columns type before field-level updates","Do not conflate tuples with UDTs; they need different update styles","Generate data-access code from the live schema"],"tags":["cql","cassandra","udt","type-mismatch"],"backgroundTag":"type-mismatch","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"}