How to create countermamily column with CQL3 in cassandra

How to create countermamily column with CQL3 in cassandra?

I used: CREATE COLUMNFAMILY userstats (username varchar PRIMARY KEY, image counter) WITH default_validation = counter AND comment = 'User Stats';

Now, when I run this in CQL3, I get: Bad Request: default_validation is not a valid keyword argument for CREATE COLUMNFAMILY

+5
source share
1 answer

CQL3 no longer adheres to the dynamic column model. It can still create arbitrarily wide cassandra rows, but they look like "normal" narrow tables in CQL, with all columns being named and defined. This is why CQL3 no longer supports installation default_validationor comparatoretc.

You must read and understand http://www.datastax.com/dev/blog/schema-in-cassandra-1-1 before doing anything non-trivial in CQL3.

The answer to your question, however, is that it is as simple as leaving default_validation:

CREATE TABLE userstats (
    username varchar PRIMARY KEY,
    images counter
) WITH comment='User Stats';

Although it is unclear whether you plan to use multiple counters for each row, as you need default_validation. If you did this, and yours comparatorwould have been varchar, you could have done:

CREATE TABLE userstats (
    username varchar,
    countername varchar,
    value counter,
    PRIMARY KEY (username, countername)
) WITH comment='User Stats';

.. images .

+3

All Articles