What would be the exact CQL3 syntax to create a counter CF with composite
row key and not predefined column names ?

Is the following supposed to work ?

CREATE TABLE composite_counter (
       aid   text,
       key1  text,
       key2  text,
       key3  text,
       value counter,
       PRIMARY KEY (aid, key1, key2, key3)
)

First, when I do so I have no error shown, but I *can't* see this CF appear
in my OpsCenter.

"update composite_counter set value = value + 5 where aid = '1' and key1 =
'test1' and key2 = 'test2' and key3 = 'test3';" works as expected too.

But how can I have multiple counter columns using the schemaless property
of cassandra ? I mean before, when I created counter CF with cli, things
like this used to work:
"update composite_counter set 'value2' = 'value2' + 5 where aid = '1' and
key1 = 'test1' and key2 = 'test2' and key3 = 'test3';" => Bad Request: line
1:29 no viable alternative at input 'value2'

I also tried:
"update composite_counter set value2 = value2 + 5 where aid = '1' and key1
= 'test1' and key2 = 'test2' and key3 = 'test3';"   => Bad Request: Unknown
identifier value2 (as expected I guess)

I want to make a counter CF with composite keys and a lot of counters using
this pattern "20130306#event" or "(20130306, event)", not sure if I should
use composite columns there.

Is it mandatory to create the CF with at least one column with the
"counter" type ? I mean I will probably never use a column named 'value', I
defined it just to be sure the CF is defined as a counter CF.




2013/3/6 Abhijit Chanda <abhijit.chan...@gmail.com>

> Thanks @aaron  for the rectification
>
>
> On Wed, Mar 6, 2013 at 1:17 PM, aaron morton <aa...@thelastpickle.com>wrote:
>
>> Note that CQL 3 in 1.1 is  compatible with CQL 3 in 1.2. Also you do not
>> have to use CQL 3, you can still use the cassandra-cli to create CF's.
>>
>> The syntax you use to populate it depends on the client you are using.
>>
>> Cheers
>>
>>    -----------------
>> Aaron Morton
>> Freelance Cassandra Developer
>> New Zealand
>>
>> @aaronmorton
>> http://www.thelastpickle.com
>>
>> On 5/03/2013, at 9:16 PM, Abhijit Chanda <abhijit.chan...@gmail.com>
>> wrote:
>>
>> Yes you can , you just have to use CQL3 and 1.1.10 onward cassandra
>> supports CQL3.  Just you have to aware of the fact that a column family
>> that contains a counter column can only contain counters. In other other
>> words either all the columns of the column family excluding KEY have the
>> counter type or none of them can have it.
>>
>> Best Regards,
>> --
>> Abhijit Chanda
>> +91-9748888395
>>
>>
>>
>
>
> --
> Abhijit Chanda
> +91-9748888395
>

Reply via email to