Marten Kenbeek created CASSANDRA-16784:
------------------------------------------
Summary: Conditional update on super column table returns too many
rows
Key: CASSANDRA-16784
URL: https://issues.apache.org/jira/browse/CASSANDRA-16784
Project: Cassandra
Issue Type: Bug
Components: Feature/Lightweight Transactions
Reporter: Marten Kenbeek
Attachments: dense_supercolumn_lwt_test.patch
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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]