Reputation: 51
CREATE TABLE mykespace.newtable (
name text PRIMARY KEY,
marks int,
score float,
value float,
value2 blob
)
cqlsh:mykespace> alter table newtable alter value type int;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Altering of types is not allowed"
cqlsh:mykespace> alter table newtable alter value2 type varint;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Altering of types is not allowed"
unable to change data type , even int to varint , and float to int
Upvotes: 3
Views: 7774
Reputation: 57748
As of Cassandra 3.10 and 3.0.11, the ability to change column data type has been removed with CASSANDRA-12443.
...because we no longer store the length for all types anymore, switching from a fixed-width to variable-width type causes issues. commitlog playback breaking startup, queries currently in flight getting back bad results, and special casing required to handle the changes.
The best workaround here, would be to drop the existing column, and create a new column with a different name (to avoid potential problems with commitlog replay). Something like:
ALTER TABLE mykeyspace.newtable DROP value;
ALTER TABLE mykeyspace.newtable ADD value_int int;
Upvotes: 9