Cassandra
  1. Cassandra
  2. CASSANDRA-3761 CQL 3.0
  3. CASSANDRA-4179

Add more general support for composites (to row key, column value)

    Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Fix Version/s: 1.2.0 beta 1
    • Component/s: API
    • Labels:

      Description

      Currently CQL3 have a nice syntax for using composites in the column name (it's more than that in fact, it creates a whole new abstraction but let's say I'm talking implementation here). There is however 2 other place where composites could be used (again implementation wise): the row key and the column value. This ticket proposes to explore which of those make sense for CQL3 and how.

      For the row key, I really think that CQL support makes sense. It's very common (and useful) to want to stuff composite information in a row key. Sharding a time serie (CASSANDRA-4176) is probably the best example but there is other.

      For the column value it is less clear. CQL3 makes it very transparent and convenient to store multiple related values into multiple columns so maybe composites in a column value is much less needed. I do still see two cases for which it could be handy:

      1. to save some disk/memory space, if you do know it makes no sense to insert/read two value separatly.
      2. if you want to enforce that two values should not be inserted separatly. I.e. to enforce a form of "constraint" to avoid programatic error.

      Those are not widely useful things, but my reasoning is that if whatever syntax we come up for "grouping" row key in a composite trivially extends to column values, why not support it.

      As for syntax I have 3 suggestions (that are just that, suggestions):

      1. If we only care about allowing grouping for row keys:
        CREATE TABLE timeline (
            name text,
            month int,
            ts timestamp,
            value text,
            PRIMARY KEY ((name, month), ts)
        )
        
      2. A syntax that could work for both grouping in row key and colum value:
        CREATE TABLE timeline (
            name text,
            month int,
            ts timestamp,
            value1 text,
            value2 text,
            GROUP (name, month) as key,
            GROUP (value1, value2),
            PRIMARY KEY (key, ts)
        )
        
      3. An alternative to the preceding one:
        CREATE TABLE timeline (
            name text,
            month int,
            ts timestamp,
            value1 text,
            value2 text,
            GROUP (name, month) as key,
            GROUP (value1, value2),
            PRIMARY KEY (key, ts)
        ) WITH GROUP (name, month) AS key
           AND GROUP (value1, value2)
        
      1. 4179.txt
        57 kB
        Sylvain Lebresne
      2. 4179-2.txt
        64 kB
        Sylvain Lebresne

        Issue Links

          Activity

          Sylvain Lebresne created issue -
          Sylvain Lebresne made changes -
          Field Original Value New Value
          Fix Version/s 1.1.1 [ 12319857 ]
          Jonathan Ellis made changes -
          Fix Version/s 1.1.2 [ 12321445 ]
          Fix Version/s 1.1.1 [ 12319857 ]
          Sylvain Lebresne made changes -
          Fix Version/s 1.1.3 [ 12321881 ]
          Fix Version/s 1.1.2 [ 12321445 ]
          Jonathan Ellis made changes -
          Fix Version/s 1.1.3 [ 12321881 ]
          Priority Major [ 3 ] Minor [ 4 ]
          Jonathan Ellis made changes -
          Link This issue blocks CASSANDRA-4285 [ CASSANDRA-4285 ]
          Sylvain Lebresne made changes -
          Assignee Sylvain Lebresne [ slebresne ]
          Sylvain Lebresne made changes -
          Attachment 4179.txt [ 12535163 ]
          Sylvain Lebresne made changes -
          Attachment 4179-2.txt [ 12536824 ]
          Sylvain Lebresne made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Labels cql3
          Fix Version/s 1.2 [ 12319262 ]
          Jonathan Ellis made changes -
          Reviewer xedin
          Sylvain Lebresne made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Jonathan Ellis made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Sylvain Lebresne made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Gavin made changes -
          Workflow no-reopen-closed, patch-avail [ 12663265 ] patch-available, re-open possible [ 12753458 ]
          Gavin made changes -
          Workflow patch-available, re-open possible [ 12753458 ] reopen-resolved, no closed status, patch-avail, testing [ 12758746 ]
          Gavin made changes -
          Link This issue blocks CASSANDRA-4285 [ CASSANDRA-4285 ]
          Gavin made changes -
          Link This issue is depended upon by CASSANDRA-4285 [ CASSANDRA-4285 ]

            People

            • Assignee:
              Sylvain Lebresne
              Reporter:
              Sylvain Lebresne
              Reviewer:
              Pavel Yaskevich
            • Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development