[ 
https://issues.apache.org/jira/browse/CASSANDRA-16643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17339903#comment-17339903
 ] 

Adam Holmberg commented on CASSANDRA-16643:
-------------------------------------------

Thanks, but looks like that one failed on github clone.

> 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
>          Components: CQL/Semantics
>            Reporter: Artem Chebotko
>            Assignee: Adam Holmberg
>            Priority: Normal
>             Fix For: 4.0-rc2, 4.0
>
>
> {{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-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to