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:

Cql map example 8a2fbfc7bb9a10453793f44759bb33c85cf52facfc52c784a3cb8a92aa593a75

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.