Let's consider a table with two columns of counter type:
cqlsh:ks> CREATE TABLE t(p int PRIMARY KEY, c1 COUNTER, c2 COUNTER);
cqlsh:ks> UPDATE t SET c1 = c1 + 1 WHERE p = 1;


We have one row now:
 p | c1 | c2---+----+------
 1 |  1 | null

My question is: should we treat the null counter (`c2` here) as zero?
E.g. this query returns an empty result set:
cqlsh:ks> SELECT * FROM t WHERE c2 = 0 ALLOW FILTERING;

 p | c1 | c2---+----+----

(0 rows)

so NULL counters are not comparable to regular integers. Makes sense in
general, but counters are specific: one could argue that since c1 := c1 + 1
ended up as 1, its previous value must have been 0 (?). On the other hand,
a counter 'nullified' by DELETE should not appear as 0...

Is this a desired (and designed) behavior? Do you think it won't change in
the future and can be relied on?

Cheers,
JS

Reply via email to