question

vinoth avatar image
vinoth asked Erick Ramirez answered

Can we alter data type to frozen collection?

Can i alter a column from non-frozen collection data type to frozen collection data type

CREATE TABLE vinoth.employee (
    emp_id int PRIMARY KEY,
    emp_city text,
    emp_name text,
    emp_sal int,
    emp_details map<text, float>
)

This below statement is not working, Is there any other way to do this?

ALTER TABLE employee ALTER emp_details TYPE frozen<map<text, float>>;
cqlcollections
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

It has not been possible to change the data type of a column for over 5 years now, in fact since Apache Cassandra 3.0.11 and 3.10 (CASSANDRA-12443). It was done because it causes a lot of issues including nodes unable to start, unable to replay commitlog mutations and other data corruption.

Additionally, dropping then re-adding a column with the same name but with a different type also causes the same issues so it has also been disallowed (CASSANDRA-14843, CASSANDRA-14948).

Attempts to use ALTER TABLE ... TYPE will return an error similar to:

InvalidRequest: Error from server: code=2200 [Invalid query] message="Altering column types is no longer supported"

Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.