Q: Create table in Cassandra with a column of tuples of arbitrary length I am trying to create a table that fits the following data:
[("US",20150914,(("GOV",7),("POL",9))),("PA",20150914,(("EDU",7),("POL",9),("MON",20))),("US",20150914,(("GOV",7)))]

I have create the following table:
CREATE TABLE gdelt.world_patterns (country varchar, date int, mention tuple <tuple<text, int>,tuple<text, int>,tuple<text, int>>, PRIMARY KEY ( country, date ) );

My problem is that Cassandra will only store my tuples of length three correctly. Is it possible for me to store tuples of any length? I'm not sure how to write this.
Here is a picture of my current table:


A: CREATE TABLE gdelt.world_patterns (
    country varchar, 
    date int, 
    mention text, ---- Json
PRIMARY KEY ( country, date ) );

Save tuple value as Json string, this way you don't have to worry about number of tuples. 
        {"tuple": {
      "country": "us",
      "date": "20150704",
      "mention": 
            [
          {"text": "value"},
          {"text": "value"},
          {"text": "value"},
           ]
    }}

Optionaly you can put contry and date in json as well.

A: You have multiple options here:
(store as text, which is o.k. but I don't think that you really want it)
Using a  map (might be best but don't know if you want to bother with decoding)
CREATE TABLE world_patterns (
    country varchar,
    date int,
    mention map<text, int>,
    PRIMARY KEY ( country, date )
);

INSERT INTO world_patterns(country, date, mention) values ('LA', 20150704, { 'US' : 20150914, 'GOV': 7, 'POL':  9}) ;

Use a list of tuples (just slight modification of your thing [] instead of () )
  CREATE TABLE world_patterns (
    country varchar,
    date int,
    mention mention list<frozen<tuple<text,int>>>,
    PRIMARY KEY (country, date)
  );

  INSERT INTO world_patterns(country, date, mention) values ('LA', 20150704, [('US', 20150914), ('GOV',7), ('POL',9)]) ;

