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

+=/-= shortcut syntax bugs/inconsistencies

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      CASSANDRA-12232 introduced (+=/-=) shortcuts for counters and collection types. I ran into some bugs/consistencies.

      Given the schema:

      CREATE TABLE simplex.collection_table (k int PRIMARY KEY, d_l List<int>, d_s Set<int>, d_m Map<int,int>, d_t Tuple<int>);
      

      1) Using -= on a list column removes all elements that match the value, instead of the first or last occurrence of it. Is this expected?

      Given d_l = [0, 1, 2, 1, 1]
      UPDATE collection_table SET d_l -= [1] WHERE k=0;
      yields 
      [0, 2]
      

      2) I can't seem to remove a map key/value pair:

      Given d_m = {0: 0, 1: 1}
      UPDATE collection_table SET d_m -= {1:1} WHERE k=0;
      yields
      Invalid map literal for d_m of type frozen<set<int>>
      

      However

      UPDATE collection_table SET d_m -= {1} WHERE k=0;

      does work.

      3) Tuples are immutable so it make sense that +=/-= doesn't apply. However the error message could be better, now that other collection types are allowed:

      UPDATE collection_table SET d_t += (1) WHERE k=0;
      yields
      Invalid operation (d_t = d_t + (1)) for non counter column d_t
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ifesdjeen Alex Petrov
                Reporter:
                kishkaru Kishan Karunaratne
                Authors:
                Alex Petrov
                Reviewers:
                Andres de la Peña
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: