[ https://issues.apache.org/jira/browse/CASSANDRA-6601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13876309#comment-13876309 ]
Aleksey Yeschenko commented on CASSANDRA-6601: ---------------------------------------------- I'm afraid you are still not getting it. bq. I would either like to be able to ask for the writetime of the columns that are part of the primary key (I can accept not being able to do it on the partition key, columns in the cluster key would be sufficient) That's impossible, because those values are encoded as parts of the cell names, and shared between all the cells belonging to a particular row, and those might have different timestamps. There is no non-ambiguous way to decide which one to return then. bq. or I would want to be able to get the writetime of the null value I wrote. This makes no sense, because there is no such thing as 'null value'. What you wrote is a tombstone, and a tombstone means that the cell is gone, and doesn't exist anymore - not returned via thrift or CQL. bq. I think I understand what's going on now, but I also think in this case that Cassandra's internals break the CQL table abstraction. Sorry, but I think you don't, and it doesn't. That said, here is the schema you want: {code} CREATE TABLE sortedset (pk int, ck int, sentinel blob, PRIMARY KEY (pk, ck)) WITH COMPACT STORAGE; {code} To insert an element, with zero overhead (one cell per set element, no row marker): {code} INSERT INTO sortedset (pk, ck, sentinel) VALUES (0, 1, 0x); {code} 0x is an empty blob, the value of the cells will be an empty byte buffer internally, so no overhead, again. But you can use it to get the writetime of the elements if you want: {code} SELECT ck, writetime(sentinel) FROM sortedset WHERE pk = 0; ck | writetime(sentinel) ----+--------------------- 1 | 1390211923196000 2 | 1390212246096000 3 | 1390212247904000 4 | 1390212251112000 {code} > 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)