cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-5723) the datetime compare not right in cql3!
Date Thu, 04 Jul 2013 15:51:48 GMT

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

Sylvain Lebresne commented on CASSANDRA-5723:
---------------------------------------------

bq. it should be fellow

No, it should be empty, because you're overwriting the same row all the time, so after that
update in 4, the row '111' should contain {{create_date='1917-05-01'}} and you could rightfully
expect to not get that row back with your query.

The reason it's actually returned is that for some reason, DateType.compare() (the comparator
used for the timestamp CQL3 type) use an unsigned comparison, and since 1917 is before the
unix epoch, it's timestamp is negative and wrongfully sort after any post-epoch date. This
is *not* a CQL3 specific bug in particular.

The simple fix would be to change the comparison to be signed, but there is obviously backward
compatibility concerns (since DateType has done that for years). In any case, in the meantime,
avoid pre-epoch dates.
                
> the datetime compare not right in cql3!
> ---------------------------------------
>
>                 Key: CASSANDRA-5723
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5723
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.2.3
>            Reporter: zhouhero
>             Fix For: 1.2.3
>
>
> - this bug can be confirmed by fellow:
> 1.create table like fellow:
> create table test2 (
> id varchar,
> c varchar,
> create_date timestamp,
> primary key(id)
> );
> create index idx_test2_c on test2 (c);
> create index idx_test2_create_date on test2 (create_date);
> 2.insert data like fellow;
> cqlsh:pgl> update test2 set create_date='1950-01-01', c='1' where id='111';
> cqlsh:pgl> update test2 set create_date='1917-01-01', c='1' where id='111';
> cqlsh:pgl> update test2 set create_date='2013-01-01', c='1' where id='111';
> 3.select data :
> cqlsh:pgl> select * from test2 where c='1' and create_date>'2011-01-01 12:00:01'
ALLOW FILTERING ;
> id | c | create_date
> -----+---+--------------------------
> 111 | 1 | 2012-12-31 15:00:00+0000
> 4. add data:
> update test2 set create_date='1917-05-01', c='1' where id='111';
> 5.select data:
> cqlsh:pgl> select * from test2 where c='1' and create_date>'2011-01-01 12:00:01'
ALLOW FILTERING ;
> id | c | create_date
> -----+---+--------------------------
> 111 | 1 | 1917-04-30 15:00:00+0000
> ↑
> the search result is not right!
> it should be fellow:
> id | c | create_date
> -----+---+--------------------------
> 111 | 1 | 2012-12-31 15:00:00+0000

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message