Kassandra: How to create a column in a supercolumn family?

I define my database model in a schema file so that later I can easily create key and column families from scratch. I looked at the schema-sample.txt file that comes with the Cassandra distribution and shows how to create standard column families using column_metadata, for example:

create column family User with comparator = UTF8Type and default_validation_class = UTF8Type and column_metadata = [ {column_name : name, validation_class : UTF8Type} {column_name : username, validation_class : UTF8Type} {column_name : City, validation_class : UTF8Type} ]; 

But how can I use a similar syntax to create a superseries family? I would like to define the column names of the super columns to be placed in the supercall family.

+4
source share
1 answer

To create the Super Column family, you need to add the column_type property:

 create column family User with column_type = 'Super' and comparator = UTF8Type and default_validation_class = UTF8Type; 

You cannot define super command names in metadata. Metadata is used to validate column values ​​or create indexes. Since you cannot check the value of a super call (the value is larger than columns), and you cannot create indexes in super calls, there is no reason to set metadata for them.

You can create metadata about auxiliary columns with super columns, but they will apply to all super columns in a row. For instance:

 create column family User with column_type = 'Super' and comparator = UTF8Type and default_validation_class = UTF8Type and column_metadata = [ {column_name : name, validation_class : UTF8Type} {column_name : age, validation_class : LongType} ]; 

In this supercolumn family, any subheading called "name" should be UTF8, and any subscript column named age should be long.

+7
source

Source: https://habr.com/ru/post/1384224/


All Articles