{"record":{"id":"e9d200c3b0ee15cb","repo":"apache/cassandra","slug":"altering-field-types-is-no-longer-supported","errorCode":null,"errorMessage":"Altering field types is no longer supported","messagePattern":"Altering field types is no longer supported","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/AlterTypeStatement.java","lineNumber":259,"sourceCode":"        }\n    }\n\n    private static final class AlterField extends AlterTypeStatement\n    {\n        private AlterField(String keyspaceName, String typeName, boolean ifExists)\n        {\n            super(keyspaceName, typeName, ifExists);\n        }\n\n        @Override\n        public boolean compatibleWith(ClusterMetadata metadata)\n        {\n            return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n        }\n\n        UserType apply(KeyspaceMetadata keyspace, UserType userType)\n        {\n            throw ire(\"Altering field types is no longer supported\");\n        }\n    }\n\n    public static final class Raw extends CQLStatement.Raw\n    {\n        private enum Kind\n        {\n            ADD_FIELD, RENAME_FIELDS, ALTER_FIELD\n        }\n\n        private final UTName name;\n        private final boolean ifExists;\n        private boolean ifFieldExists;\n        private boolean ifFieldNotExists;\n\n        private Kind kind;\n\n        // ADD","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/AlterTypeStatement.java#L241-L277","documentation":"Altering the type of an existing field inside a user-defined type (UDT) is no longer allowed in this version of Cassandra. The AlterTypeStatement's FieldTypeAlteration.apply() unconditionally raises this InvalidRequestException because field-type changes broke serialization compatibility and were removed. Developers must create a new UDT instead of mutating field types in place.","triggerScenarios":"Executing `ALTER TYPE <keyspace>.<type> ALTER <field> TYPE <newtype>` — the statement's kind is an AlterFieldType alteration, which is dispatched to apply() and always throws.","commonSituations":"Scripts ported from older Cassandra versions that relied on ALTER TYPE ... ALTER; schema migration tooling generating field type changes; developers renaming/refactoring UDT field types after deployment.","solutions":["Remove the ALTER TYPE ... ALTER statement; Cassandra no longer supports changing field types","Create a new UDT with the desired field types and a new column (or migrate via a new table), then drop the old one","Add a new field with the new type and migrate data via application-level reads/writes, then remove the old field if acceptable","Audit schema-migration scripts and guard them to fail fast on unsupported ALTER TYPE ALTER operations"],"exampleFix":"// before\nALTER TYPE address ALTER zip TYPE int;\n\n// after\nCREATE TYPE address_v2 (street text, zip int);\n-- migrate data, then swap the column and drop the old type","handlingStrategy":"validation","validationCode":"// Check the DDL before executing\nif (/\\bALTER\\s+TYPE\\s+\\S+\\s+ALTER\\b/i.test(cql)) {\n  throw new Error('ALTER TYPE field-type changes are unsupported; create a new UDT instead');\n}","typeGuard":"function isAlterTypeFieldChange(stmt) {\n  return /^ALTER\\s+TYPE\\s+\\S+\\s+ALTER\\b/i.test(stmt.trim());\n}","tryCatchPattern":"try {\n  session.execute(\"ALTER TYPE address ALTER zip TYPE int\");\n} catch (e) {\n  if (e.code === 8704 || /Altering field types is no longer supported/.test(e.message)) {\n    // fall back to create-new-UDT migration path\n  } else throw e;\n}","preventionTips":["Never generate ALTER TYPE ... ALTER in schema migration tooling","Treat UDT field types as immutable; evolve via new UDT versions","Add a lint rule in migration scripts banning ALTER TYPE ALTER","Test schema migrations against a cluster running the target Cassandra version"],"tags":["cassandra","cql","udt","unsupported-operation"],"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"}