How to remove fields from an UDT

Hi everyone!

Is there any way that I can remove fields from an UDT?

Using the superheroes example from the docs, is there any way to remove the phone field from the address type?

I understand that there is no ALTER TYPE address DROP phone and I have also tried creating a new type without the phone field and running a alter table ... alter type <new type> but Scylla reports the types as incompatible.

In my case, I have an UDT with lots of fields and a large portion of them are not used anymore, so I’d like to just remove them. Is this possible in any way?


We don’t support removing fields or altering fields to incompatible types because it would open pandora’s box of misery. In effect, we only allow backward compatible changes to UDT, such that reading old values of the same type, with the new definition can work.

I think the best course of action for you is to add a new field to your table, with a new UDT type and write new values to this new column. On the read side, you can check for the new column and fall back to the old one if that is missing.

You can also run a script which scans the entire table and re-writes values from the old column, into the new one, allowing you to drop the old column. This might save you some space. Unused columns in an UDT value do take up a little bit of space.

1 Like

Got it. Thanks for the quick answer!