Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Correctness
-
Normal
-
Normal
-
User Report
-
All
-
None
-
Description
CREATE TABLE does not allow mixing counter and non-counter columns in the same table. However, this can be done with ALTER TABLE:
- ALTER TABLE can add non-counter columns to a table with counter columns;
- ALTER TABLE can add counter columns to a table with non-counter columns.
Tested in cassandra-4.0-rc1 (also in cassandra-4.0-beta2):
CREATE TABLE test1 ( id UUID, my_counter COUNTER, PRIMARY KEY ((id)) ); ALTER TABLE test1 ADD my_text TEXT; UPDATE test1 SET my_counter = my_counter + 10, my_text = 'Test 1' WHERE id = 5069cc15-4300-4595-ae77-381c3af5dc5e; SELECT * FROM test1; id | my_counter | my_text --------------------------------------+------------+--------- 5069cc15-4300-4595-ae77-381c3af5dc5e | 10 | Test 1
CREATE TABLE test2 ( id UUID, my_text TEXT, PRIMARY KEY ((id)) ); ALTER TABLE test2 ADD my_counter COUNTER; UPDATE test2 SET my_counter = my_counter + 20, my_text = 'Test 2' WHERE id = 5069cc15-4300-4595-ae77-381c3af5dc5e; SELECT * FROM test2; id | my_counter | my_text --------------------------------------+------------+--------- 5069cc15-4300-4595-ae77-381c3af5dc5e | 20 | Test 2
CREATE TABLE test3 ( id UUID, my_counter COUNTER, my_text TEXT, PRIMARY KEY ((id)) ); InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot mix counter and non counter columns in the same table"