Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-12232

Add +=/-= shortcut syntax

    XMLWordPrintableJSON

    Details

      Description

      For collections and counters, the current syntax to add/remove elements is:

      UPDATE foo SET myCollection = myCollection + ...;
      

      which is fine, though it's already tad annoying to have to repeat myCollection.

      But moving forward, with tickets CASSANDRA-7826, we'll start being able to add to nested collections and we'll end up with queries like:

      UPDATE foo SET myCollection['someElement']['otherElemnt'] = myCollection['someElement']['otherElemnt'] + ...;
      

      where the repetition is starting to be really annoying and it makes the query less readable.

      It's trivial however to add a +=/-= shortcut syntax which would read instead:

      UPDATE foo SET myCollection['someElement']['otherElemnt'] += ...;
      

      As this would just be syntactic sugar, it only requires a few minor addition to the grammar and this would be completely optional: if some users prefer the verbose syntax, that's fine.

      Also note that while this will be even more useful after things like CASSANDRA-7826, it's already a nice to have today so it's not dependent on that latter ticket in any way.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ifesdjeen Alex Petrov
                Reporter:
                slebresne Sylvain Lebresne
                Authors:
                Alex Petrov
                Reviewers:
                Benjamin Lerer
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: