How to define dynamic column families in cassandra

It says that no special effort is required to get a dynamic family of columns. But I always get an exception when I try to set a value for an undefined column.

I created a column family like this:

CREATE TABLE places ( latitude double, longitude double, name text, tags text, PRIMARY KEY (latitude, longitude, name) ) 

BTW: I needed to define a tag column. Can someone explain to me why? Maybe because all the other columns are part of the index?

Now when you insert such data:

 INSERT INTO places ("latitude","longitude","name","tags") VALUES (49.797888,9.934771,'Test','foo,bar') 

It works just fine! But when I try:

 INSERT INTO places ("latitude","longitude","name","tags","website") VALUES (49.797888,9.934771,'Test','foo,bar','test.de') 

I get the following error:

 Bad Request: Unknown identifier website text could not be lexed at line 1, char 21 

What changes are needed so that I can add columns dynamically?

I am using Cassandra 1.1.9 with CQL3 using cqlsh directly on the server.

+6
source share
2 answers

CQL3 supports a dynamic column family, but you need to change the table schema first

 ALTER TABLE places ADD website varchar; 

View 1.2 documentation and CQL in depth slides

+11
source

CQL3 requires column metadata. CQL3 is actually an abstraction over the underlying rows of stores, so it is not one-to-one. If you want to use dynamic column names (and there are many great usage examples for them), use the traditional Thrift interface (through the client library of your choice). This will give you complete control over what will be saved.

+7
source

All Articles