1
votes

Is it possible to define map collection in CQL3 which would then be readable as group of columns in Thrift?

Based on https://www.datastax.com/dev/blog/thrift-to-cql3 when mixing static and dynamic columns, the dynamic ones are not visible from CQL3. The recommended way is to use collections. However, when defining collections in non-compact-storage table, it is not visible in thrift at all. When defining it as frozen and compact-storage, it's visible as single column.

create table main.exp2 (
    article_id blob primary key,
    text text,
    scantime int,
    info text,
    rest frozen<map<text, blob>>) WITH COMPACT STORAGE;

Did I miss some, possibly undocumented option? Do I have too old version of library?

Alternatively, where would be good place for asking for this as new feature? Obviously, with thrift being deprecated, I can't expect any change in storage itself, however based on explanation on the thrift-to-cql3 page, I would expect there is some way how to provide the data to thrift with composite column names.

Motivation is sort of forward compatibility - preparing table so it can be used by current applications with thrift, but also by new applications with CQL3. Currently it seems that such combination is only possible with completely dynamic tables.

Although if there is 64KB limit for length of value in map collection, as mentioned on https://docs.datastax.com/en/cql/3.3/cql/cql_reference/refLimits.html , we can't use it anyway.

So maybe asking for the feature of reading dynamic columns of mixed table from CQL3 makes more sense ...

EDIT: Note that I am aware that I can define the table without any static columns, like this:

create table main.exp1 (
    article_id blob,
    column_key text,
    value blob,
    PRIMARY KEY (article_id, column_key)
) WITH COMPACT STORAGE AND CLUSTERING ORDER BY (column_key ASC);

but that means all my values are blob, including the ones I know about in advance.

1

1 Answers

0
votes

I would simply rollout the map into separate rows by adding a new clustering column to distinguish the values. For your design you can also move the common parts into static columns, so they will be always returned. The table structure could look something like this:

create table main.exp2 (
    article_id blob,
    text text static,
    scantime int static,
    info text static,
    rest_key text,
    rest_value blob,
    primary key (article_id, rest_key)
    );

P.S. Thrift is going away in next version, so it's better to convert everything into CQL