You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Artem Chebotko (Jira)" <ji...@apache.org> on 2021/04/29 21:49:00 UTC
[jira] [Created] (CASSANDRA-16643) ALTER TABLE: mixing counter and
non-counter columns in one table
Artem Chebotko created CASSANDRA-16643:
------------------------------------------
Summary: ALTER TABLE: mixing counter and non-counter columns in one table
Key: CASSANDRA-16643
URL: https://issues.apache.org/jira/browse/CASSANDRA-16643
Project: Cassandra
Issue Type: Bug
Reporter: Artem Chebotko
{{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):
{code:sql}
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
{code}
{code:sql}
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
{code}
{code:sql}
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"
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org