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

Conditional update on super column table returns too many rows

    XMLWordPrintableJSON

    Details

    • Platform:
      All
    • Impacts:
      None

      Description

      We have a (dense) supercolumn table that we're trying to upgrade from 2.2 to 3.x. On this table we perform conditional updates on one of the values using a CQL query. In 2.2 this works as expected: the query returns either a single-column row with true, or a two-column row with false and the current value.

      In 3.x this query is internally rewritten to work on a map, using a Maps.SetterByKey operation. The update itself is applied correctly, but when the condition fails and the update is not applied, the query returns all values in the supercolumn/map instead of just the value of the subcolumn/key from the where clause.

      In particular, since it returns just the values, and not the keys/mapping, there's no way to know which of the values is the value of the row we're trying to update.

       

      – Super column table (created through Thrift)
       CREATE TABLE store.shopping_items (
       key text,
       column1 text,
       column2 text,
       "" map<text, text>,
       value text,
       PRIMARY KEY (key, column1, column2)
       ) WITH COMPACT STORAGE;
      – Create some data
       cqlsh:store> INSERT INTO shopping_items (key, column1, column2, value) VALUES ('item1', 'default', 'id', '1');
       cqlsh:store> INSERT INTO shopping_items (key, column1, column2, value) VALUES ('item1', 'default', 'color', 'blue');
      – This query returns multiple rows
       cqlsh:store> UPDATE shopping_items SET value ='2' WHERE key ='item1' AND column1 = 'default' AND column2 = 'id' IF value = null;
      [applied] | value
       ----------+-----------
       False | 'blue'
       False | '1'
      

       

      See the attached patch for a test that succeeds on 2.2, but fails with the described behavior on 3.0 and on the latest 3.11. 

        Attachments

        1. dense_supercolumn_lwt_test.patch
          1 kB
          Marten Kenbeek

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              knbk Marten Kenbeek
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: