[ 
https://issues.apache.org/jira/browse/CASSANDRA-9842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15066724#comment-15066724
 ] 

Sylvain Lebresne edited comment on CASSANDRA-9842 at 8/4/16 9:13 AM:
---------------------------------------------------------------------

You're right, there is an inconsistency there.

To sum it up, the problem is that if we update a static column {{sc}} with a 
{{IF sc == null}} condition, whether or not the condition is applied changes 
simply by the virtue of deleting a (already non existing) partition. That is, 
if a partition {{p}} doesn't pre-exist,
{noformat}
UPDATE t SET scol = 0 WHERE p = 0 IF scol = null
{noformat}
is not applied, but
{noformat}
DELETE FROM t WHERE p = 0;
UPDATE t SET scol = 0 WHERE p = 0 IF scol = null
{noformat}
does apply, even though the initial deletion should be a no-op for all intent 
and purposes.

The question could then be which of those answer is the right one. And that's 
probably the first response: we do want to make a difference between a 
partition that exists but has no value for a specific static column and one 
that doesn't exist at all. We do make that difference in {{SELECT}} in 
particular so it would be inconsistent not to do it. I will note however that 
on 3.0, the result of those 2 examples is actually consistent, but it returns 
{{true}} in both case (while, as I argue before we kind of want to return 
{{false}} in both cases) and changing that will require a bit of special casing 
in the condition handling code.

Lastly, I'll note that this problem is quite different from the initial problem 
for which the ticket was raised so I'll update the title to reflect that (as 
noted by Jonathan, the behavior in the ticket description is actually correct).


was (Author: slebresne):
You're right, there is an inconsistency there.

To sum it up, the problem is that if we update a static column {{sc}} with a 
{{IF sc == null}} condition, whether or not the condition is applied changes 
simply by the virtue of deleting a (already non existing) partition. That is, 
if a partition {{p}} doesn't pre-exist,
{noformat}
UPDATE t SET scol = 0 WHERE p = 0 IF scol = null
{noformat}
is not applied, but
{noformat}
DELETE FROM t WHERE p = 0;
UPDATE t SET scol = 0 WHERE p = 0 IF scol = null
{noformat}
doesn't apply, even though the initial deletion should be a no-op for all 
intent and purposes.

The question could then be which of those answer is the right one. And that's 
probably the first response: we do want to make a difference between a 
partition that exists but has no value for a specific static column and one 
that doesn't exist at all. We do make that difference in {{SELECT}} in 
particular so it would be inconsistent not to do it. I will note however that 
on 3.0, the result of those 2 examples is actually consistent, but it returns 
{{true}} in both case (while, as I argue before we kind of want to return 
{{false}} in both cases) and changing that will require a bit of special casing 
in the condition handling code.

Lastly, I'll note that this problem is quite different from the initial problem 
for which the ticket was raised so I'll update the title to reflect that (as 
noted by Jonathan, the behavior in the ticket description is actually correct).

> Inconsistent behavior for '= null' conditions on static columns
> ---------------------------------------------------------------
>
>                 Key: CASSANDRA-9842
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9842
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: cassandra-2.1.8 on Ubuntu 15.04
>            Reporter: Chandra Sekar
>            Assignee: Alex Petrov
>             Fix For: 2.1.15, 2.2.7, 3.0.8, 3.8
>
>         Attachments: 9842-2.1.txt, 9842-3.0.txt
>
>
> Both inserting a row (in a non-existent partition) and updating a static 
> column in the same LWT fails. Creating the partition before performing the 
> LWT works.
> h3. Table Definition
> {code}
> create table txtable(pcol bigint, ccol bigint, scol bigint static, ncol text, 
> primary key((pcol), ccol));
> {code}
> h3. Inserting row in non-existent partition and updating static column in one 
> LWT
> {code}
> begin batch
>     insert into txtable (pcol, ccol, ncol) values (1, 1, 'A');
>     update txtable set scol = 1 where pcol = 1 if scol = null;
> apply batch;
> [applied]
> -----------
>      False
> {code}
> h3. Creating partition before LWT
> {code}
> insert into txtable (pcol, scol) values (1, null) if not exists;
> begin batch
>     insert into txtable (pcol, ccol, ncol) values (1, 1, 'A');
>     update txtable set scol = 1 where pcol = 1 if scol = null;
> apply batch;
> [applied]
> -----------
>      True
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to