Generating Cassandra CQL Collections

Maps

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


yields:

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

Lists

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.