Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "Cassandra2474" page has been changed by JonathanEllis: http://wiki.apache.org/cassandra/Cassandra2474?action=diff&rev1=4&rev2=5 Comment: add composite PRIMARY KEY proposal Discussion starts [[https://issues.apache.org/jira/browse/CASSANDRA-2474?focusedCommentId=13171304&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13171304|here]] {{{ + -- "column" and "value" are sparse; a transposed row will be stored as + -- two columns of (posted_at, 'column': string) and (posted_at, 'value': blob), + -- with C* row key of user_id CREATE TABLE timeline ( - userid int primary key, + user_id int, posted_at uuid, - posted_by int, - body text + column string, + value blob, + PRIMARY KEY(user_id, posted_at) ) TRANSPOSED; }}} {{{ + -- entire transposed row is stored as a single dense composite column + -- (ts1, cat, subcat, 1337, 92d21d0a-...: []) with a C* row key of series. + -- Note that the composite column's value is unused in this case. CREATE TABLE events ( - series text primary key, + series text, ts1 int, cat text, subcat text, "1337" uuid, - "92d21d0a-d6cb-437c-9d3f-b67aa733a19f" bigint + "92d21d0a-d6cb-437c-9d3f-b67aa733a19f" bigint, + PRIMARY KEY(series, ts1, cat, subcat, "1337", "92d21d0a-d6cb-437c-9d3f-b67aa733a19f") + ) - ) TRANSPOSED WITH COLUMN NAMES ("1337" int, "92d21d0a-d6cb-437c-9d3f-b67aa733a19f" uuid); + TRANSPOSED WITH COLUMN NAMES ("1337" int, "92d21d0a-d6cb-437c-9d3f-b67aa733a19f" uuid); }}} - - ''Consider calling this TRANSPOSED WITH COLUMN TYPES'' - === Examples === `SELECT`, `INSERT`, and `UPDATE` syntax require no changes. Some examples: @@ -162, +168 @@ Only minimal CQL changes are required. The Hive metastore would need to be updated to understand the TRANSPOSED syntax. Normal SELECTs and UPDATEs are supported, including "SELECT *," a weakness of the Beta proposals. - This proposal originally included a SPARSE option for handling supercolumns and supercolumn-like composites, where a component of the composite name is itself a column name in the transposed row: instead of component X always representing the same column name, the component would contain the column name. Jonathan dropped this extension in the face of objections from Sylvain when it became clear that fixed-structure composite types can support ALTER .. ADD COLUMN with a minor change (https://issues.apache.org/jira/browse/CASSANDRA-3657). + With the addition of the PRIMARY KEY syntax, this allows for specifying both "sparse" and "dense" data layouts, without the SPARSE keyword that some found unappealing. It also improves conceptual integrity with existing C* practice, namely, that row keys are not update-able. So, the tradeoff is straightforward: include a column in the PRIMARY KEY if you want it to be part of the positional CompositeType tuple (and be more space efficient); leave it out if you want to update it. - Without SPARSE, this proposal does not support supercolumns. + This also allows supporting SuperColumns, should we choose to do so.
