cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Yeschenko (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-6601) WRITETIME of a null value does not return a time
Date Mon, 20 Jan 2014 09:03:21 GMT

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

Aleksey Yeschenko commented on CASSANDRA-6601:
----------------------------------------------

bq. SELECT value FROM foo WHERE pk = 1 AND ck = 2;

There is a row here, with one cell - the row marker. 'value' column is not present here, so
you get 1 row in your result set, but 'null' for 'value', because it's doesn't exist in this
row.

bq. SELECT value FROM foo WHERE pk = 2 AND ck = 3;

The is a row here, with two cells - the row marker and 'value', Hence you get 1 row in your
result set, with 'value' existing, and being equal to 4.

bq. SELECT value FROM foo WHERE pk = 3 AND ck = 4;

There is no row here, not even the row marker, so the result set is entirely empty.

{quote}
DELETE FROM foo WHERE pk = 2 AND ck = 3;
SELECT value FROM foo WHERE pk = 2 AND ck = 3;
{quote}

You've removed the whole row with a range tombstone here. The whole row - the two cells -
the row marker and the cell containing your '4' value, and now the result is equivalent to
the previous case. Empty result set.

{quote}
UPDATE foo SET value = null WHERE pk = 2 AND ck = 3;
SELECT value FROM foo WHERE pk = 2 AND ck = 3;
{quote}

You are not updating the value to be null. This UPDATE query will create two cells internally
- create the row marker and a tombstone for the 'value' cell. The result set will not be empty,
because there will be a row - with just the row marker, but no 'value', hence the null.

There is a difference between a single cell not existing (you will see 'null' in its place
in the resultset) and a row not existing at all (you will get an entirely empty result set
then).

I don't know how to explain it better. If you need more details, you'll have to read the source
code. Just, please, don't rely on cassandra-cli to understand 'the internals'. It doesn't
show you the internals. Don't draw any conclusions from it. If you want a peak at the inside,
use sstable2json on the sstables - only this way you can see the whole picture, with tombstones
and all.

> WRITETIME of a null value does not return a time
> ------------------------------------------------
>
>                 Key: CASSANDRA-6601
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6601
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Cassandra 2.0.2
>            Reporter: Theo Hultberg
>
> When a cell's value is {{null}} the CQL {{WRITETIME}} function returns null. I was expecting
it to return a timestamp. Looking at the data in {{cassandra-cli}} I can see that the cell
has a timestamp.
> Here's a session showing the issue:
> {code}
> cqlsh> CREATE KEYSPACE writetime_test WITH replication = {'class': 'SimpleStrategy','replication_factor':
'1'};
> cqlsh> USE writetime_test;
> cqlsh:writetime_test> CREATE TABLE writetime_test_table (pk INT, ck INT, value INT,
PRIMARY KEY (pk, ck));
> cqlsh:writetime_test> INSERT INTO writetime_test_table (pk, ck, value) VALUES (1,
2, null);
> cqlsh:writetime_test> SELECT WRITETIME(value) FROM writetime_test_table WHERE pk =
1 AND ck = 2;
>  writetime(value)
> ------------------
>              null
> (1 rows)
> cqlsh:writetime_test> INSERT INTO writetime_test_table (pk, ck, value) VALUES (2,
3, 4);
> cqlsh:writetime_test> SELECT WRITETIME(value) FROM writetime_test_table WHERE pk =
2 AND ck = 3;
>  writetime(value)
> ------------------
>  1389967663822000
> (1 rows)
> cqlsh:writetime_test> SELECT WRITETIME(value) FROM writetime_test_table WHERE pk =
3 AND ck = 4;
> (0 rows)
> {code}
> I first insert data where the cell value is {{null}}. When I query its writetime I get
a row back, but the timestamp is {{null}}.
> I then insert a row with a value, and get a timestamp in the query results, as expected.
> Finally I query for the writetime of a cell that does not exist, and get no rows back,
just to show that there's a difference between calling {{WRITETIME}} on {{null}} and on something
that doesn't exist.
> Even though the value is {{null}} the cell exists and it has a timestamp. I can clearly
see the timestamp using {{cassandra-cli}}:
> {code}
> [default@unknown] use writetime_test;
> Authenticated to keyspace: writetime_test
> [default@writetime_test] list writetime_test_table;
> Using default limit of 100
> Using default cell limit of 100
> -------------------
> RowKey: 1
> => (name=2:, value=, timestamp=1389967959822000)
> -------------------
> RowKey: 2
> => (name=3:, value=, timestamp=1389967964749000)
> => (name=3:value, value=00000004, timestamp=1389967964749000)
> {code}
> The reason I want to get the {{WRITETIME}} of a {{null}} value is that I have a table
where I don't care about the value, I use the column keys as sorted set. I still want to know
when some of them were written though, but I can't ask for the {{WRITETIME}} of something
that is part of the primary key, so I must use the (otherwise unused) value.
> A workaround is to write some dummy value in the cell, and that's probably what I need
to do, but this felt like it was a bug, it was at least not what I expected.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message