I am trying to update a user defined type in Cassandra with a renamed field. This is my alter statement.
ALTER TYPE test.test_type RENAME a TO b;
This works fine and doing DESC TYPE test.test_type
shows me the new schema. But I have a table with a schema like
col1 text PRIMARY KEY
col2 frozen<test_type>
and this does not seem to have been updated.
If I run SELECT * FROM test_table
I get the old type fields
c1 | c2
--------+------------
value1 | {a: 'a1'}
If I try to insert, I am forced to use the new type
INSERT INTO test_table (c1, c2) VALUES ('value2', {a: 'a2'});
InvalidRequest: code=2200 [Invalid query] message="Unknown field 'a' in value of user defined type test_type"
But even when I insert with the new type, I still get the old fields.
INSERT INTO test_table (c1, c2) VALUES ('value2', {b: 'a2'});
SELECT * FROM test_table;
c1 | c2
--------+------------
value1 | {a: 'a1'}
value2 | {a: 'a2'}
I've also tried running ALTER TABLE
to re-type the column with the new type, adding a new column to the table with type frozen<test_type>
, and even dropping the table and recreating it (which isn't even an option in production). No matter what, the type stays the same when I select from it.
How am I supposed to actually change the type?
Found the issue is logged in this Jira. https://issues.apache.org/jira/browse/CASSANDRA-9188
Restarting cqlsh will return the values that you expect. The underlying table and type has been properly modified, it's just that cqlsh has a bug where it will not return the update values until cqlsh is restarted.