Tuple type

You can use a tuple as a convenient alternative to a user-defined type.

Cassandra 2.1 introduces the tuple type that holds fixed-length sets of typed positional fields. You can use a tuple as an alternative to a user-defined type when you don't need to add new fields. A tuple can accommodate many fields (32768), more than you can prudently use. Typically, you create a tuple having only a few fields.

In the table creation statement, use angle brackets and a comma delimiter to declare the tuple component types. Surround tuple values in parentheses to insert the values into a table, as shown in this example.

CREATE TABLE collect_things (
  k int PRIMARY KEY,
  v <tuple<int, text, float>>
);

INSERT INTO collect_things (k, v) VALUES(0, (3, 'bar', 2.1));

SELECT * FROM collect_things;

 k | v
---+-----------------
 0 | (3, 'bar', 2.1)
Note: Cassandra 2.1.0 to 2.1.2 requires using frozen for tuples:
frozen <tuple <int, tuple<text, double>>>
Cassandra 2.1.3+ does not require this keyword for tuples.

You can filter a selection using a tuple.

CREATE INDEX on collect_things (v);

SELECT * FROM collect_things WHERE v = (3, 'bar', 2.1);

 k | v
---+-----------------
 0 | (3, 'bar', 2.1)

You can nest tuples as shown in the following example:

create table nested (k int PRIMARY KEY, t frozen <tuple <int, tuple<text, double>>>);

INSERT INTO nested (k, t) VALUES (0, (3, ('foo', 3.4)));