[ 
https://issues.apache.org/jira/browse/CASSANDRA-2474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13098112#comment-13098112
 ] 

Jonathan Ellis commented on CASSANDRA-2474:
-------------------------------------------

bq. I haven't found a better data model for that kind of example than using a 
composite column name where the name is (timestamp, category, sub-category, 
eventId).

This is exactly the "dense" composite column case we've been discussing.

I make three claims:

- A more Cassandra-ish way to model this would be to encode this as a series of 
columns: (<timestamp>, 'category', <category>), (<timestamp>, 'subcategory', 
<subcategory>), (<timestamp>, 'event', <eventId>).  This is better in the 
general case for the same reason that a sparse top-level set of columns is 
better: I can easily add more data to events (e.g., "source") without rewriting 
existing events.
- The component syntax is much, much better at handling sparse queries, and 
adequate for handling dense ones; the destructuring syntax is terrible at 
sparse queries while good at dense ones, and the : syntax doesn't handle sparse 
queries at all, or at least nobody's put forth an explanation of how that would 
work.
- the .. syntax is a bad fit for CQL and should be deprecated in favor of 
transposed queries.

Here is how we can do your examples with the component syntax and 
transposition.  I'm using "sparse" encoding here, but as described above "the 
component proposal" handles dense as well, just with more "AS" entries.

- Give me all the events for time t, category c and sub-category sc.
{code}
SELECT component1 as timestamp, category, subcategory, event
FROM events.transposed
WHERE timestamp = ? AND category = ? AND subcategory = ?
{code}
- Give me all the events for time t and category c1 to c2 (where c1 < c2 for 
the category sorting)
{code}
SELECT component1 as timestamp, category, subcategory, event
FROM events.transposed
WHERE timestamp = ? 
  AND c1 < category AND category <= c2
{code}
- Give me everything for the last 4 hours
SELECT component1 as timestamp, category, subcategory, event
FROM events.transposed
WHERE timestamp > ? 
{code}

(If you're just joining us, the reason .. syntax is bad is that it's a one-off 
that doesn't allow the full expresivity you get with WHERE clauses -- I gave 
some examples in 
https://issues.apache.org/jira/browse/CASSANDRA-2474?focusedCommentId=13087705&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13087705)

bq. We can resolve this question by writing email to the cassandra mailing list 
and let people decide

More bikeshedding by people who know less about the subject isn't going to help 
here.

> CQL support for compound columns
> --------------------------------
>
>                 Key: CASSANDRA-2474
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2474
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: API, Core
>            Reporter: Eric Evans
>            Assignee: Pavel Yaskevich
>              Labels: cql
>             Fix For: 1.0
>
>         Attachments: screenshot-1.jpg, screenshot-2.jpg
>
>
> For the most part, this boils down to supporting the specification of 
> compound column names (the CQL syntax is colon-delimted terms), and then 
> teaching the decoders (drivers) to create structures from the results.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to