adeline
adeline

Reputation: 91

How to data model wide rows using cql

I am doing cassandra update from version 1 to version 3, and replace the thrift API with CQL, and redo the data model using CQL. But I found one table is a little difficult to translate to CQL

The old definition is like this:

CREATE COLUMN FAMILY vsc_data
WITH key_validation_class='CompositeType(LongType, IntegerType)'
AND comparator = 'CompositeType(LongType,LongType)';

And the data looks like this:

{1,11111,[(2222222,3333333,value1,value2),(4444444,555555,value3,value4)...]}

The "1" and "11111" is composite row key, and "2222222" and "3333333" is composite column key, when query,the data should be sorted first by "2222222",then by "3333333" column.

So how can I data model this using CQL and how to query it?

Upvotes: 0

Views: 161

Answers (1)

doanduyhai
doanduyhai

Reputation: 8812

Thrift schema

CREATE COLUMN FAMILY vsc_data
WITH key_validation_class='CompositeType(LongType, IntegerType)'
AND comparator = 'CompositeType(LongType,LongType)';

CQL schema

CREATE TABLE vsc_data (
     partition1 bigint,
     partition2 int,
     clustering1 bigint,
     clustering2 bigint,
     value1 ???,
     value2 ???, 
     PRIMARY KEY((partition1, partition2), clustering1, clustering2)
);

Upvotes: 2

Related Questions