Generating Cassandra CQL Collections


To generate a map of key-value pairs, name multiple fields with a common prefix followed by a ".". For example:


insert into MY_TABLE (location) values ({'country':'Norway','city':'Oslo'});


To generate a list of values, simply add brackets containing the number of items you want to generate to the end of the field name.

For example, "friends[3]" would result in a value like:

insert into MY_TABLE (friends) values (['Joe Smith', 'Sally Brown', 'Mike Jones']);

If you would like a random number of items, specify a range in brackets. For example, "friends[2-5]" would result in 2 to 5 values being generated per record.